I stumbled upon an error during a simple multiplication that rather surprised me. What is happening here, I always assumed *
was only for matrix multiplication.
x = 2;
y = zeros(1,4);
y(1) = 1 *x;
y(2) = x* 1;
y(3) = (x *1);
y(4) = x *1;
y
x *1
Will give the following output:
y =
2 2 2 1
Error: "x" was previously used as a variable,
conflicting with its use here as the name of a function or command.
See MATLAB Programming, "How MATLAB Recognizes Function Calls That Use Command Syntax" for details.
Does anyone understand what is going on here? Of course I verified that x
is not a function.