Plotting of an inline function
9 ビュー (過去 30 日間)
古いコメントを表示
str=input('Give an equation in x\n','s');
f=inline(str,'x');
I want to plot a graph of the function 'f'. I tried fplot but it is not working. How can I plot 'f' vs. 'x'.
10 件のコメント
Stephen23
2018 年 8 月 31 日
編集済み: Stephen23
2018 年 8 月 31 日
"What toolbox is required for this?"
Use an internet search engine to find this page:
Read the text in the top left corner of that page:
Symbolic Math Toolbox
Use an internet search engine to search for "MATLAB what toolbox licenses do I have"
... etc
回答 (2 件)
Stephen23
2018 年 8 月 31 日
編集済み: Stephen23
2018 年 8 月 31 日
str = input('Give an equation in x: ','s');
fun = str2func(sprintf('@(x)%s',str));
fplot(fun,[0,10])
And tested:
>> str = input('Give an equation in x: ','s');
Give an equation in x: sqrt(x)-x
>> fun = str2func(sprintf('@(x)%s',str));
>> fplot(fun,[0,10])

0 件のコメント
Star Strider
2018 年 8 月 31 日
See: how do you user input a equation in matlab ? i used inline function but unable to plot the equation. suppose i want my input equation as x-cos(x). and than plot it. how do i do it? Is the following code correct ? (link). This seems to be the same homework problem!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Function Creation についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!