Clear Filters
Clear Filters

Defining anonymous with other anonymous functions.

2 views (last 30 days)
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.

Accepted Answer

Matt J
Matt J on 30 Oct 2013
Edited: Matt J on 30 Oct 2013
V = @(h) Vbody + Vlungs(h) + Vsuit(h);

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!