How to plot a functions in matlab

1 回表示 (過去 30 日間)
maharaj
maharaj 2013 年 2 月 23 日
回答済み: Fernando Fernandes 2019 年 11 月 26 日
x ranges from 10-50 and y = [exp(-x)/x] - [exp(-(2+x))/(2+x)]

採用された回答

the cyclist
the cyclist 2013 年 2 月 23 日
x = 10:0.1:50;
y = (exp(-x)./x) - (exp(-(2+x))./(2+x));
plot(x,y)

その他の回答 (2 件)

Youssef  Khmou
Youssef Khmou 2013 年 2 月 23 日
編集済み: Youssef Khmou 2013 年 2 月 23 日
1. Using function handle :
>>f=@(x) (exp(-x)./x)-(exp(-(2+x))./(2+x))
>>x=10:0.1:50;
>>plot(x,f(x))
2. Alternative using again Function Handle ;
>>f=@(x) (exp(-x)./x)-(exp(-(2+x))./(2+x))
>>fplot(f,[10 50])
3. Using M function in M file :
% Save the function in M file
function y=R(x)
y=(exp(-x)./x)-(exp(-(2+x))./(2+x));
%------------------------------------
% In the command prompt :
>>x=[10:0.01:50];
>>figure, plot(x,R(x))
4. Using Symbolic variables :
>>syms x
>>f=(exp(-x)./x)-(exp(-(2+x))./(2+x))
>>ezplot(f,[10 50])

Fernando Fernandes
Fernando Fernandes 2019 年 11 月 26 日
How could I plot a function of two variables r_d and t_d? I'd like to keep r_d constant and plot t_d.. after I want to keep t_d constant and plot r_d. The function is: q(r_d, t_d)=exp((-r_d)^2/(4*t_d))

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by