Defining anonymous with other anonymous functions.

1 次查看(过去 30 天)
Could somebody tell me why the following code returns the following error?? 'Undefined function 'plus' for input arguments of type 'function_handle'.'
Error in @(h)Vbody+Vlungs+Vsuit
EDU>> rhow = 1025;
g = 9.81;
P0 = 101325;
gamma = 1.4;
m = 67;
Vbody = 0.06;
Vlungs0 = 0.004;
tol = 0.01;
%Anonymous Functions:
P = @(h) P0 + rhow * g * h;
Vlungs = @(h) ((P0)/(P))^(1/gamma) * Vlungs0;
Vsuit = @(h) 0.005 * exp(-0.035*h);
V = @(h) Vbody + Vlungs + Vsuit;
EDU>> V(2)
I give all my constants numerical values and then define the anonymous functions Vlungs and Vsuit, both are functions of h. Finally, I attempt to define another anonymous function V, which is also a function of h, using Vbody (a constant) and the two previously defined functions of h Vlungs and Vsuit. Is this not allowed and if not, is there a way around this? Thanks.

采纳的回答

Matt J
Matt J 2013-10-30
编辑:Matt J 2013-10-30
V = @(h) Vbody + Vlungs(h) + Vsuit(h);

更多回答(0 个)

类别

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