Info
This question is closed. Reopen it to edit or answer.
How can i overcome this error?
1 view (last 30 days)
Show older comments
I'm entering the following statements in MATLAB(COMMAND WINDOW) after pressing enter, i'm getting the following error:
ERROR: Subscript indices must either be real positive integers or logicals.
Question: % given x(n1), y(n2), w(n3).
% compute the following
% c(n4)=x(-n1+2)
% d(n5)=y(-n2-3)
% e(n6)=w(-n3)
% u(n7)=x(n1)+y(n2-2)
% b(n8)=x(n1)*w(n3+4)
% s(n9)=y(n2)-w(n3+4)
% r(n10)=3.5*y(n2)
n1=-3:1:3;
x=[-4 5 1 -2 -3 0 2];
n2=-1:1:5;
y=[6 -3 -1 0 8 7 -2];
n3=2:1:8;
w=[3 2 2 -1 0 -2 5];
Theoretically i'm getting the output but practically not getting.
Can anyone tell the reason why i'm not getting the output........
2 Comments
Walter Roberson
on 4 Oct 2012
To check, the only executable lines of code are the n1 through w lines? You do not have any subscript indexing in any of those lines.
Jan
on 4 Oct 2012
@Srikanth: Please post the complete error message, which contain the line, which cuases the error, also.
@Walter: I cannot test it currently, but what happens for:
horzcat = 1;
x = [-4, 5];
While Matlab 6.5 preferred the built-in function horzcat(), modern Matlab versions could try to use the variable instead.
Answers (1)
Sachin Ganjare
on 4 Oct 2012
You cannot address the 0-th row or column (element) in MATLAB.
Refer link below for further details:
Hope it helps!!!
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!