can FOR and WHILE loop combined together?

18 ビュー (過去 30 日間)
farhah muhammad
farhah muhammad 2022 年 1 月 26 日
コメント済み: farhah muhammad 2022 年 4 月 11 日
HI,
im trying to do coding to reveal the stage, for example:
sum of urine output is less than 0.5 ml/hr from 6-12 hours = category 1
sum of urine output is less than 0.5 ml/hr from 12 hours and above = category 2
sum of urine output is less than 03 ml/hr from 24 hrs and above = category 3.
is this correct?
sumUO = 0;
while PatientStruct.Urine (i) >= 24
aki_stage = 0;
sumUO = sumUO + PatientStruct.Urine(i);
while PatientStruct.Urine (i) >= 12
sumUO = sumUO + PatientStruct.Urine(i);
aki_stage = 0;
if sumUO < 0.5
aki_stage = aki_stage + 2;
return;
end
end
if sumUO < 0.3
aki_stage = aki_stage + 3;
return;
end
AKI_stageUO (i,1) = aki_stage;
end
thank you in advanced!
  2 件のコメント
Geoff Hayes
Geoff Hayes 2022 年 1 月 26 日
@farhah muhammad - I think you need to discuss the structure of your data. Do you have results for each hour? Is that what i represents, an hour (note this variable never changes...)?
farhah muhammad
farhah muhammad 2022 年 1 月 27 日
Yes, I have result for every hour, but it depends on patients, it could be data for 48 hours, 36 hours or until the patients discharge from the ward. tq

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

回答 (1 件)

Esha Chakraborty
Esha Chakraborty 2022 年 4 月 8 日
Hi Farhah,
I understand that you want to know whether for and while loop can be combined.
Yes, you can nest the while loop inside the for loop. I will suggest you to use for loop for iterations of the range of time and while loop for the urine output.
You can refer to this similar example in the link below for further insights:
  1 件のコメント
farhah muhammad
farhah muhammad 2022 年 4 月 11 日
thank you for your help! yes, it works! ;)

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by