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 件)

Stephen23
Stephen23 2023 年 2 月 14 日
編集済み: Stephen23 2023 年 2 月 14 日

0 投票

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 ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2022b

タグ

質問済み:

2023 年 2 月 14 日

編集済み:

2023 年 2 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by