New to MATLAB...can't find what's wrong in this code....

1 Ansicht (letzte 30 Tage)
Gowri Kurup
Gowri Kurup am 14 Aug. 2011
Bearbeitet: Walter Roberson am 23 Sep. 2016
a=2;
x=0.5;
for i=1:1000
{
plot(i,x);
x = a*x-a*x.^2);
}
end
I'm trying to plot a logistics map....but I keep getting the error: "The expression to the left of the equals sign is not a valid target for an assignment."
Can someone help me?
  1 Kommentar
Yoav Livneh
Yoav Livneh am 14 Aug. 2011
You don't need to put the code in the for loop inside curly braces. Also you have a ")" that dosn't belong on "x = a*x-a*x.^2);"
What are you trying to do? Are you trying to plot all 1000 values of x together? Because in your code each iteration of the for loop will overwrite the previous plot.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Muhammad shahbaz
Muhammad shahbaz am 14 Aug. 2011
the '{}' should be removed,nothing else is wrong,go on with it.

Weitere Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by