The expression to the left of the equals sign is not a valid target for an assignment.

Basic question about MATLAB programming
Post Reply
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

Re: The expression to the left of the equals sign is not a valid target for an assignment.

Post by matlab1 »

This error happens in MATLAB, when the left side of an equation or command can not save the result of a command.

for example :


sum2 = 10
in3 = [2,3]
if( y = in3 )
sum_y = sum2 +1;
end

In the top m-file, there is error in the if-command.

The in3 variable is a matrix, but the y variable is a number, so this line of the program produces an error.

Solution :

sum2 = 10
in3 = [3]
if( y == in3 )

sum_y = sum2 +1;
end
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests