how to put a function with conditions in a parent function

4 Ansichten (letzte 30 Tage)
Fatma Hadj salem
Fatma Hadj salem am 6 Apr. 2021
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
dpb
dpb am 7 Apr. 2021
Good catch on the use of t, Walter. I overlooked it, indeed.
Fatma Hadj salem
Fatma Hadj salem am 8 Apr. 2021
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,

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by