function or functions of a single variable

조회 수: 24 (최근 30일)
Michel Lopes Villaluz
Michel Lopes Villaluz 2020년 5월 25일
댓글: Alejandro Peñuelas 2020년 5월 25일
  댓글 수: 2
Alejandro Peñuelas
Alejandro Peñuelas 2020년 5월 25일
Hi. Please in the future write explicitly what is your question and can also use the code tool for questions instead of pasting screenshots. By doing so, we can help you efficiently.
Alejandro Peñuelas
Alejandro Peñuelas 2020년 5월 25일
Friend, if one of the answers helped you, mark it as the accepted answer to help other users with issues like this.

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

답변 (3개)

Ameer Hamza
Ameer Hamza 2020년 5월 25일
You need to pass a function handle
fplot(@(x) -exp(-x)+x.^2+2*x+2, [0 1])
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 5월 25일
In current releases, character vectors are still accepted, but in future that facility will go away.
The real problem was that e is not going to be recognized as the base of the natural logarithms, so e and x would both be considered to be variables.

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


Walter Roberson
Walter Roberson 2020년 5월 25일
편집: Walter Roberson 2020년 5월 25일
fplot('-exp(-x)+x.^2-2*x+2',[0 1])
As far as fplot() is concerned, e is just another variable, and not the base of the natural logarithms.

Alejandro Peñuelas
Alejandro Peñuelas 2020년 5월 25일
The problem you are not defining the function used in fplot as an expresion with an specific variable. You also are trying to use 'e' as the 'exp()' function.
Try something like this:
% Define x as the variable of the function with @(x)
fplot( @(x) -exp(-x + x.^2 - 2*x + 2), [0, 1]);
Maybe the function is not correct but you only have to change it according to your needs.
Hope this can help you. Bye.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by