Borrar filtros
Borrar filtros

Creating a simple plot

1 visualización (últimos 30 días)
Vaultec
Vaultec el 1 de Oct. de 2014
Editada: Rick Rosson el 1 de Oct. de 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

Respuesta aceptada

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

Más respuestas (2)

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

Vaultec
Vaultec el 1 de Oct. de 2014
ok thanks worked out perfectly

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by