# Reg:error in matlab

1. Jun 10, 2013

### supraja

i have tried for an hour but have been constantly getting an error saying "The expression to the left of the equals sign is not a valid target for an assignment".what should i do?

i need the expression
E=[Z*(r-1/D)+exp(Z*(r-1/D))-1].*exp(-r.*Z).*1/(r-1/D).^2 ;

2. Jun 10, 2013

### kreil

How do you define the rest of the variables (r, D, Z)? You posted only one line of code but I think the rest is relevant, since for example if I use dummy numbers I don't get an error:

Code (Text):

r=2;
D=2;
Z=2;
E=[Z*(r-1/D)+exp(Z*(r-1/D))-1].*exp(-r.*Z).*1/(r-1/D).^2

E =

0.1798

This error comes about when you try to do something such as,

Code (Text):
if i = 2
if i = 2
|
Error: The expression to the left of the equals sign is not a valid target for an assignment.
You were trying to see IF i was equal to 2, but instead you assigned a value of 2 to i. The correct syntax would be,

Code (Text):

if i == 2
%do stuff
end

Last edited: Jun 10, 2013