How to link two functions
Mostra commenti meno recenti
Hello all,
I am want to link following two programs: In first program(trial.m), I am calling fsolve function to solve for system of non linear equations which is stored in second function loaddistr. The two functions trial.m and loaddistr.m are as follows:
%trial curvesumi=0.2017; curvesumo=0.1377; distar=0.6031; dostar=0.6577; mateprop=1e-4*[0.1011 0.0910];
ki=(2/(curvesumi*distar))^(3/2).*curvesumi./(1.5.*mateprop);
ko=(2/(curvesumo*dostar))^(3/2).*curvesumo./(1.5.*mateprop);
Kn=(1./((1./ki).^(1/1.5)+(1./ko).^(1/1.5))).^1.5;
m0=[0.35,0.15,0.05];
p=fsolve(@loaddistr,m0);
function n = loaddistr( m ) Fr=8900; Pd=0.015; Z=9;
Kn=3.5893e+005;
Jr=[0.1156,0.1590,0.1892,0.2117,0.2288,0.2416,0.2505,0.2559,0.2576,0.2546,0.2289,0.1871,0.1339,0.0711];
eps=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.67, 2.5, 5.0];
n=[m(1)-0.5*(1-0.5*Pd/m(3));
m(3)-Pd/2-(Fr/(Z*Kn*m(2)))^(1/1.5);
m(2)-spline(eps,Jr,m(1))];
end
If you notice I am using Kn term in both programs. I want to transfer this Kn value directly from trial.m to loaddistr.m, without separately specifying it in loaddistr.m So can someone please guide me about the code which will allow me to solve for loaddistr.m by using the Kn value from trial.m.
Thanks in advance,
Nikhil
9 Commenti
sixwwwwww
il 11 Ott 2013
Hi Nikhil, you are getting two values of Kn in your first code(trial). Which value you want to pass to second function(loaddistr)?
Nikhil
il 11 Ott 2013
sixwwwwww
il 11 Ott 2013
For Kn you get these two values 3.2307e5 and 3.5893e5. So you want to pass both values to loaddistr.m?
Nikhil
il 11 Ott 2013
Nikhil
il 11 Ott 2013
Nikhil
il 11 Ott 2013
sixwwwwww
il 11 Ott 2013
wait i do it for you. Surely you can't define function like this. I do it wait
Nikhil
il 11 Ott 2013
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!