index must be a positive integer or logical. error in matlab
Info
This question is closed. Reopen it to edit or answer.
Show older comments
n = 2;
m=2*(n-1)+1;
theta=pi/m;
for i=1:n
y(i) = cos((1-i+(m-1)/2)*theta);
y(i-1)=cos((1-(i-1)+(m-1)/2)*theta); < --- line error
end
How could I rewrite this code to be able to get the y-1 matrix
Answers (1)
Roger Stafford
on 2 Mar 2014
0 votes
You will have to rethink how your y vector is to be indexed. It cannot accept index values of zero which you have used here: when i is equal to 1 you would be indexing y(i-1) as y(0).
1 Comment
Jonathan Guarneros
on 2 Mar 2014
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!