Plotting a function with an array of x returns one y value
Afficher commentaires plus anciens
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

Réponses (1)
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)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


