How to write a function of x in a function?
조회 수: 5 (최근 30일)
이전 댓글 표시
Angel Hiram Torres Mota
2020년 3월 8일
댓글: Angel Hiram Torres Mota
2020년 3월 8일
Im just getting started in Matlab and I cant figure this out
I want to write a function of x and then the value of x inside a function
For example a = Evaluate((x^2)+1, 2)
And I want it to give me the answer. Which should be 5.
function [a] = Evaluate(f(x),x)
end
Thanks!
댓글 수: 0
채택된 답변
Walter Roberson
2020년 3월 8일
function a = Evaluate(f, x)
a = f(x);
end
Which might be called like
Evaluate(@(x) (x^2)+1, 2)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!