Plotting a function with an array of x returns one y value

Hey all!
I am trying to plot a specific problem and cannot seem to have it plot correctly
This is currently the code in which i am using. I have tried mulitple iterations as to get it to work. I either recieve a blank plot or a straight line plot.
x = -2:0.1:16;
y = (4*cos(x))/(x + exp(-0.75*x));
plot (x,y)
Either this or
y = (4*cos(x))/(x + exp(-0.75*x));
fplot (y, [-2 16])
And yet the plot should look something like this

Respuestas (1)

Stephen23
Stephen23 el 14 de Feb. de 2023
Editada: Stephen23 el 14 de Feb. de 2023
You won't get very far using MATLAB if you do not learn the difference between array and matrix operations:
Tip: if you are not doing linear algebra, then you probably want to use array operations.
x = -2:0.1:16;
y = (4*cos(x))./(x + exp(-0.75*x));
% ^^ RDIVIDE, not MRDIVIDE
plot (x,y)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Etiquetas

Preguntada:

el 14 de Feb. de 2023

Editada:

el 14 de Feb. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by