how to run a recursive solution
1 view (last 30 days)
Show older comments
Oluyemi Jegede
on 7 Feb 2014
Answered: David Sanchez
on 7 Feb 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 Comments
Accepted Answer
David Sanchez
on 7 Feb 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 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!