how to run a recursive solution
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Oluyemi Jegede
el 7 de Feb. de 2014
Respondida: David Sanchez
el 7 de Feb. de 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 comentarios
Respuesta aceptada
David Sanchez
el 7 de Feb. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!