MATLAB: What does “Error: ()-indexing must appear last in an index expression” mean

codeindexingproblem

I entered this to try to graph the points but I got the following error. What did I do wrong?
t = 0:100:1000;
v1 = t(1-sin(t))(cos(t));
v2 = sin(t)(1-(tcos(t)));
v3 = (1/7)((3sin(t))+(2tcos(t))-(5tsin(t)cos(t));
plot3 (v1,v2,v3,'*');
Error: ()-indexing must appear last in an index expression

Best Answer

You need to use multiply operators between the ( ) expressions to multiply them. MATLAB does not do this automatically. E.g.,
v1 = t .* (1-sin(t)) .* (cos(t));
v2 = sin(t) .* (1-(t .* cos(t)));
v3 = (1/7) .* ((3*sin(t))+(2*t .* cos(t))-(5*t .* sin(t) .* cos(t)));
Also, since t is a vector, you need to use the element-wise operator .* instead of the matrix multiply operator * when doing the multiplies with two vectors as operands.
Your plot isn't going to be very meaningful with a stepping of 100 between points for the sin( ) and cos( ). You should drop that stepping value to some fraction of a circle to make the plot meaningful (e.g., pi/16).