how can i write a program to receive an orbitrary function from user and then it draw the function on the interval between a to b ?

回答 (1 件)

David Hill
David Hill 2021 年 1 月 30 日

0 投票

Look at str2func
f=str2func(input('Input a function of a single variable to be graphed [e.g., @(x)x.*cos(x)-x.^2.*sin(x)]','s'));
a=0;
b=pi;
x=linspace(a,b,1000);
plot(x,f(x));

カテゴリ

ヘルプ センター および File Exchange で Modeling についてさらに検索

質問済み:

2021 年 1 月 30 日

回答済み:

2021 年 1 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by