Parse error at '>' and at 'end'

11 ビュー (過去 30 日間)
Nicholas
Nicholas 2023 年 7 月 21 日
コメント済み: VBBV 2023 年 7 月 21 日
trying to run a simple for loop as shown in my code below but I'm not sure why I'm getting Parse Errors at '<' and 'end'. Any suggestions?
T = 473.15;
t = 0;
% initial values for temperature and time
n = 0;
% prompt for steps
Tf = 323.15;
for T > Tf
% until the temperature drops to 50 degrees Celsius
T = T + n * -7.38105;
% Heun's Method without iterations
t = t + n * 60;
% Time Progression
n = n + 1;
% Step Progression
fprintf('Temperature: %d\n', T);
fprintf('Time: %d\n', t);
fprintf(' \n')
end

採用された回答

VBBV
VBBV 2023 年 7 月 21 日
while T > Tf
  1 件のコメント
VBBV
VBBV 2023 年 7 月 21 日

Use a while loop instead of for loop. The for loop can be used when there are incremental steps in the iteration process.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by