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일
편집: 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에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by