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

답변 (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)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


