Having trouble graphing a non-linear graph

x = -2:0.1:2;
y = cos(x)+exp(-1/2*x.^2)*sin(6*x)
plot(x,y)
This is my code, I keep getting
Error in test (line 2) y = cos(x)+exp(-1/2*x.^2)*sin(6*x);
But I cant figure out what I am doing wrong.

 Respuesta aceptada

Stephan
Stephan el 16 de Sept. de 2018
Editada: Stephan el 16 de Sept. de 2018
x = -2:0.01:2;
y = cos(x)+exp(-1/2*x.^2).*sin(6*x);
plot(x,y)

2 comentarios

Nirvan Hashemian
Nirvan Hashemian el 16 de Sept. de 2018
Thank you!
Neelanjan Pal
Neelanjan Pal el 16 de Nov. de 2019
Editada: Neelanjan Pal el 16 de Nov. de 2019
when the code is as SUCH;
syms x y C
x = -2:0.01:2;
C=12/(cos(x)+exp(-1/2*x.^2).*sin(6*x));
plot(x,C)
error:
Error using /
Matrix dimensions must agree.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Sept. de 2018

Editada:

el 16 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by