Code to input function
2 ビュー (過去 30 日間)
古いコメントを表示
I want to make a code where user can input the the function and as the output they get plot of f(x) vs x and also the roots of that non linear equation.
0 件のコメント
回答 (2 件)
David Hill
2022 年 8 月 29 日
Plotting would not be a problem, but finding all the roots is a problem. Recommend looking at fzero
a=input('Function (example: @(x)x.*cos(x)-x.^2.*sin(x)+exp(-x)): ','s');
f=str2func(a);
x=-pi:.001:2*pi;
plot(x,f(x));
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!