MATLAB: Error sign not valid

errorfunctionMATLAB

I have this function
n = 1;
Product = 1;
while( Product < N )
{
Product = Product * (2*n);
n = n + 1;
}
end
and this error keeps on popping up Error: File: Untitled5.m Line: 5 Column: 9 The expression to the left of the equals sign is not a valid target for an assignment.

Best Answer

That's not valid MATLAB syntax. In particular, the curly brackets shouldn't enclose the while loop. (You also used capital N where you had been using small n.)
Does this do what you intend?
n = 1;
Product = 1;
while( Product < n )
Product = Product * (2*n);
n = n + 1;
end