I want a program in which the user enters the function and the program display or plot that function

2 次查看(过去 30 天)
val=input("Enter Function",'s');
func= str2func( ['@(x) ' val ] );
x=(1:5);
y=func(x);
disp(y)
this is an example code that i wrote but code does not support x^2 and other amount of x^"any number"

采纳的回答

Antoni Garcia-Herreros
编辑:Antoni Garcia-Herreros 2023-5-10
Hello Amir,
When you input your function you need to add the dot , just like this: x.^n

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by