How to put a function in another function?
显示 更早的评论
For instance, if there are two functions which are with respect to x: f(x) = x^2 and g(x) = 4*x, I want to make another function using them: h(x) = (f(x)+5*g(x))/(2*f(x)*g(x))
But,
f = @(x) x^2;
g = @(x) 4*x;
h = @(x) (f+5*g)/(2*f*g);
doesn't work.
Is there any way to do this?
采纳的回答
更多回答(1 个)
the cyclist
2016-3-21
You have to supply the function arguments:
h = @(x) (f(x)+5*g(x))/(2*f(x)*g(x));
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!