Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How do I repeat an iteration with newly generated initial conditions if a statement is false? I wrote code that gives me values i need, however if the difference between the values is not smaller than 0.5, I need the loop to restart.
1 回表示 (過去 30 日間)
古いコメントを表示
I need help putting all of this into one big loop
- Guess initial value
- My code uses the guess to generate multiple T and Z values, these are the imporant ones --> T(5) and Z(4)
- If T(5) - (20-55/22*Z(4)) < 0.5 is true then plot (x,T) ,
- If it is false then a new guess needs to be generated using (new guess) = (previous guess) - (previous Z4 value) and put into my code to generate another T(5) and Z(4)
- The process needs to repeat until step 3 prduces a graph .
This is the code that generates T and Z values
h = 0.01;
A = 8000/11;
T(1)=80;
x(1)=0;
prompt = ('Guess initial Z value');
Z(1) = input(prompt);
for i=2:5
x(i) = x(i-1)+h;
T(i) = T(i-1) + h*Z(i-1)
Z(i) = Z(i-1) + h*(A*(T(i-1)-20));
end
3 件のコメント
回答 (0 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!