return a function without e.g. f(5)
이전 댓글 표시
I have never used Matlab before so it really is difficult for me as I now have a task in math course that says to interpolate a function with Lagrange.
My problem has nothing to do with the interpolation itself, more a question if something is possible and if so, how.
E.g. I say
f = @(x) x^3;
and p = @(x) f(2)*x
Matlab display p exactly like above but i would want it to display it as
p = @(x) 8*x
as is wouldn't make much sense to have the result as a polynomial with f(...) as values.
so i hope someone can help me with that.
답변 (1개)
Walter Roberson
2015년 6월 30일
If you have the symbolic toolbox,
syms x
p = matlabFunction(f(2)*x, x);
You did well, by the way, to realize that it was a matter of what was displayed rather than a matter of how it would execute.
댓글 수: 4
Marvin van Stegen
2015년 7월 1일
Walter Roberson
2015년 7월 2일
syms x
p = matlabFunction( expand( (x+2)*(x-1) ), x);
Marvin van Stegen
2015년 7월 2일
편집: Marvin van Stegen
2015년 7월 2일
카테고리
도움말 센터 및 File Exchange에서 Code Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!