Creating a simple plot
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
Rick Rosson
il 1 Ott 2014
Modificato: Rick Rosson
il 1 Ott 2014
Use .* instead of * here:
y = x.*exp(-x.^2);
Also, you will want higher resolution:
x = -3:0.01:3;
0 Commenti
Più risposte (2)
Michael Haderlein
il 1 Ott 2014
You need element-wise multiplication:
x = -3:3;
y = x.*exp(-x.^2); %<-- here, I added the point
plot (x, y)
0 Commenti
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!