how to put a function with conditions in a parent function

4 次查看(过去 30 天)
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 个评论
Fatma Hadj salem
Fatma Hadj salem 2021-4-8
Thank you very much! I am modifying my code according to your advice which helps me a lot,
I put the (t) just to know if it was the error ...
Thank you again and have a nice day,

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by