Creating a simple plot

5 vues (au cours des 30 derniers jours)
Vaultec
Vaultec le 1 Oct 2014
Modifié(e) : Rick Rosson le 1 Oct 2014
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

Réponse acceptée

Rick Rosson
Rick Rosson le 1 Oct 2014
Modifié(e) : Rick Rosson le 1 Oct 2014
Use .* instead of * here:
y = x.*exp(-x.^2);
Also, you will want higher resolution:
x = -3:0.01:3;

Plus de réponses (2)

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

Vaultec
Vaultec le 1 Oct 2014
ok thanks worked out perfectly

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by