Im trying to plot y=x*e^(-x^2) where the range of x is from -3,3
Ive tried running
x = -3:3; y = x*exp(-x.^2); plot (x, y) however i keep getting the error Inner matrix dimensions must agree. Not quite sure what that means

 Akzeptierte Antwort

Rick Rosson
Rick Rosson am 1 Okt. 2014
Bearbeitet: Rick Rosson am 1 Okt. 2014

0 Stimmen

Use .* instead of * here:
y = x.*exp(-x.^2);
Also, you will want higher resolution:
x = -3:0.01:3;

Weitere Antworten (2)

Michael Haderlein
Michael Haderlein am 1 Okt. 2014

0 Stimmen

You need element-wise multiplication:
x = -3:3;
y = x.*exp(-x.^2); %<-- here, I added the point
plot (x, y)
Vaultec
Vaultec am 1 Okt. 2014

0 Stimmen

ok thanks worked out perfectly

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by