Can I have the user input a non linear equation?

조회 수: 3 (최근 30일)
Amruth Chundi
Amruth Chundi 2016년 8월 16일
댓글: Amruth Chundi 2016년 8월 16일
I have to take user's input( a non- linear equation, say f(x) ) and plot it against x and find the solutions using different numerical methods. I have tried inline , str2func, @(x) and nothing's working. For example, user should be able to give f(x) = exp(-x) - x = 0 or f(x) = 600x^4 -550x^3 +200x^2 -70 = 0 and the code should plot it and find its solutions ( the solutions' part is easier to handle but I am stuck at the plot thing)

답변 (1개)

Torsten
Torsten 2016년 8월 16일
  댓글 수: 1
Amruth Chundi
Amruth Chundi 2016년 8월 16일
I used this : str = input('Enter the Non-linear Fucntion : ', 's') ; f = str2func(['@(x)' str]);
And errors I got : Undefined function or variable 's'.
Error in Q1 (line 3) f = str2func(['@(x)' str]);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by