Issue with ezplot and fplot?

1 回表示 (過去 30 日間)
K Dani
K Dani 2018 年 8 月 28 日
回答済み: Star Strider 2018 年 8 月 28 日
Maybe I'm not understanding the logistics of ezplot and fplot, but I just need to plot the function f(x) = x-2*exp(-x). When I use either function, the plot is incorrect.
syms x
fx1 = ezplot(x-2*exp(-x))
fx2 = fplot(x-2*exp(-x))
Additionally, I tried creating a loop to generate y values and plot them against x but that is also not working as the y values are incorrect. This is the loop I've tried:
clear all
close all
x = 1:1000;
for i = 1:1000
fx(i) = i - 2*exp(-i);
end
plot(x,fx)
This seems like such an easy task so I'm not certain why I'm having so much trouble. I assume it's something small I'm overlooking.

採用された回答

Star Strider
Star Strider 2018 年 8 月 28 日
I get the same result for all three plots, except for a slightly different y-axis scale with ezplot.
syms x
figure
fx1 = ezplot(x-2*exp(-x), [0 1000]);
figure
fx2 = fplot(x-2*exp(-x), [0 1000]);
The exp term goes quickly to zero:
exp_term = exp(-[1, 10, 100, 1000])
exp_term =
0.36788 4.54e-05 3.7201e-44 0
so you will not see any effect on the line where ‘x’ dominates.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by