MATLAB: I get “In an assignment A(:) = B, the number of elements in A and B must be the same.” error when I execute the following code.

fixed-point iterationwhile loop

while error1 && error2 && error3 >0.00005
x(n+1)=(log(x(n)^2)-sin(y)+(3*x(n)/2));
y(n+1)=(cos(y(n))- cos(x(n))+(y(n)/2));
z(n+1)=log(y(n)^2)+sin(x(n)*y(n));
error1=abs((x(n+1)-x(n))/x(n+1));
error2=abs((y(n+1)-y(n))/y(n+1));
error3=abs((z(n+1)-z(n))/z(n+1));
x(n)=x(n+1);
y(n)=y(n+1);
z(n)=z(n+1);
n=n+1;
end

Best Answer

Do you need to index the sin(y) as as sin(y(n)) in this line:
x(n+1)=(log(x(n)^2)-sin(y(n))+(3*x(n)/2));
Related Question