Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Error message confusion, help!

5 ビュー (過去 30 日間)
Edward
Edward 2013 年 10 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, when I try to run my program, the workspace displays the error "Error: The expression to the left of the equals sign is not a valid target for an assignment." for this line of code:
dP=((100/(std(y)*(2*pi)^0.5))*exp(-(x.^2)/(2*(std(y)^2))));
However, I have this exact same line written above, I literally copy and pasted it (except dP=dN and y=z above), and there is no error message there.
What am I doing wrong??
Thanks in advance!

回答 (4 件)

Walter Roberson
Walter Roberson 2013 年 10 月 18 日
You can have that happen if the previous line appears to be incomplete to the parser, so that the parser thinks the new assignment is in the middle of a statement.

sixwwwwww
sixwwwwww 2013 年 10 月 18 日
Dear Edward, I tried following and it is working properly:
x = 1:10;
y = 2:2:20;
dP = (100 / (std(y) * (2 * pi)^0.5)) * exp(-(x.^2) / (2 * (std(y)^2)));
Maybe you use "clear all" to clear your variable space to clear all variables before running the code and also if problem remains then try to share the complete code so that error could be sorted accordingly

Image Analyst
Image Analyst 2013 年 10 月 18 日
Did you have that code in an m-file called dP.m? This is not the error message that 2013 releases would give, but you may have an old version and I'm not sure what error message they would give for that situation. What is your m-file called? Put the lines
whos dP
which -all dP
in front of that line of code and tell us what it says.

Edward
Edward 2013 年 10 月 24 日
Never mind now, I closed and restarted Matlab a couple of times and the problem seemed to resolve itself, thanks anyway though!

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by