how to put a function with conditions in a parent function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone ^^
Objective : I want to put a function (F1) 'with conditions' in another one (F2) ==> F2 = fct(F1)
I have implemented the attached code, which I can't get to work! knowing that the function (F1) works fine by itself,
error message : 'Not enough input arguments in F2' I have tried many things but I can't understand the error, if anyone can help me out of this problem, I would be very grateful,
thank you in advance!
function f = F2(R,t)
t = [0:0.1:48]';
V = 1.408 + 1;
K1= 0.034701409774022;
r = F1(t);
f = (1/V).*(1-exp(-((t.*V.*K1)+((t.*V)./(R.*r)))));
function r = F1(t)
p1 = 2.585*10^(-06);
p2 = -9.23*10^(-05);
p3 = 0.001032;
p4 = -0.002989;
p5 = 0.7562;
mask = t <= 27;
r(mask) = p1.*t(mask).^4 + p2.*t(mask).^3 + p3.*t(mask).^2 + p4.*t(mask) + p5;
mask = t > 27;
r(mask) = 1;
end
end
4 Kommentare
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!