I'm trying to graph a function on an interval, and the graph either doesn't show up or is the wrong graph

11 ビュー (過去 30 日間)
Kyle
Kyle 2022 年 9 月 20 日
回答済み: Voss 2022 年 9 月 20 日
x = linspace(-2,16,100);
y = (4*cos(x))./(x.*exp(x.*-0.75));
plot(x,y)
Here is my code, and when i run it, the graph is not the same as when i graphed the funcion on a calculator.
I have to graph F(x) = 4cosx / x+e^(-0.75x) on the interval -2≤x≤16
How would i plot this graph without it giving me errors, and have enough points to make the graph smooth.

回答 (1 件)

Voss
Voss 2022 年 9 月 20 日
x = linspace(-2,16,100);
% y = (4*cos(x))./(x.*exp(x.*-0.75));
y = (4*cos(x))./(x+exp(x.*-0.75));
% ^ <---- here: "+" not ".*"
plot(x,y)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by