how to run a recursive solution
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Oluyemi Jegede
le 7 Fév 2014
Réponse apportée : David Sanchez
le 7 Fév 2014
load 'gastemperature.m'
Tgbv=gastemperature(i)
load 'gastemperaturetestcell.m'
Tgtc=gastemperaturetestcell(i)
Tgbv1=gastemperature(i+1)
Tgtc1=gastemperaturetestcell(i+1)
load 'watertemperature.m'
Tw=watertemperature(i)
h=input('enter h value')
P=1.5922
[Ta,P]=hworkf( Ta,P,h,Tgbv,Tgtc,Tw,Tgbv1,Tgtc1 )
while P<1.66 &Ta<330.15
return
end
Please help with the following issues:
- how do i write the code such that it runs recursively until the condition 'P<1.66 &Ta<330.15' is met?
- Tgbv,Tgtc,Tw,Tgbv1& Tgtc1 are each from an array of data. How do I write the code such that a new value is picked from these arrays upon every solution
- how do I write the code such that the Ta and P from each solution is taken into the next solution
- how do i save the outputs(Ta and P) from each iteration as arrays? thanks.
0 commentaires
Réponse acceptée
David Sanchez
le 7 Fév 2014
1.- % make sure you have defined a value for ( Ta,P,h,Tgbv,Tgtc,Tw,Tgbv1,Tgtc1 ). In your code above Ta is missing
load 'gastemperature.m'
Tgbv=gastemperature(i)
load 'gastemperaturetestcell.m'
Tgtc=gastemperaturetestcell(i)
Tgbv1=gastemperature(i+1)
Tgtc1=gastemperaturetestcell(i+1)
load 'watertemperature.m'
Tw=watertemperature(i)
h=input('enter h value')
P=1.5922
[Ta,P]=hworkf( Ta,P,h,Tgbv,Tgtc,Tw,Tgbv1,Tgtc1 )
solutions(1,:) = [Ta,P];
i = 2;
while (P<1.66 & Ta<330.15)
Tgbv=gastemperature(i);
Tgtc=gastemperaturetestcell(i);
Tgbv1=gastemperature(i+1);
Tgtc1=gastemperaturetestcell(i+1);
Tw=watertemperature(i);
[Ta,P]=hworkf( Ta,P,h,Tgbv,Tgtc,Tw,Tgbv1,Tgtc1 );
solutions(i,:) = [Ta,P];
i = i +1;
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!