Clear Filters
Clear Filters

how to run a recursive solution

1 view (last 30 days)
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:
  1. how do i write the code such that it runs recursively until the condition 'P<1.66 &Ta<330.15' is met?
  2. 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
  3. how do I write the code such that the Ta and P from each solution is taken into the next solution
  4. how do i save the outputs(Ta and P) from each iteration as arrays? thanks.

Accepted Answer

David Sanchez
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

More Answers (0)

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!