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
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!