Plot a matrix which has functions
古いコメントを表示
I have these functions (in a script):
fx = @ (x) exp(-x.^2);
f1x = @ (x) 1/(x.^2+1);
fpx = f1x/int(f1x,x,0,1)
I want to plot a table with {fx,fpx} when {x,0,1}.
How can I do this?
採用された回答
その他の回答 (1 件)
Paulo Silva
2011 年 1 月 26 日
disp('Executing the function, please wait')
steps=0.05;
%increase steps to speed up execution, accuracy will be lower
%decrease steps to improve accuracy, you have to wait more time
x=0:steps:1;
fx=inline('exp(-x.^2)');
f1x=inline('1./(x.^2+1)');
fpx=sym(f1x)./int(sym(f1x));
fpx=subs(fpx,'x',x);
fx=subs(fx,'x',x);
Table=[fx;fpx];
plot(fx,fpx)
disp('All done, you can find the result in variable Table')
4 件のコメント
Ned Gulley
2011 年 1 月 26 日
Hi Paulo: You might want to just edit your old answer to correct it rather than creating a new answer.
Paulo Silva
2011 年 1 月 26 日
Hi Ned, I will use the edit next time, thanks.
George
2011 年 1 月 27 日
Paulo Silva
2011 年 1 月 27 日
I have no idea about what could be wrong, it's working here in Matlab 2008b (32bits), here's the result http://img254.imageshack.us/img254/5666/46107520.jpg
カテゴリ
ヘルプ センター および File Exchange で Numerical Integration and Differentiation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!