Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Reg:error in matlab

  1. Jun 10, 2013 #1
    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 ;


    please reply asap
     
  2. jcsd
  3. Jun 10, 2013 #2

    kreil

    User Avatar
    Gold Member

    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
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Reg:error in matlab
  1. Matlab Error (Replies: 1)

  2. Error code in Matlab (Replies: 3)

Loading...