how to write the script file for condition statement and loops?

Please help to show how to write the script files for this question? Thank you.
How many days, and which dates in the month, was the new infected victims>200, 100≤new infected victims≤200and new infected victims<50 using conditional statements and loops?

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 5 日

0 投票

If your data is in a Table array format, then it is best to use logical indexing that is many times faster and efficient than loop and conditional coding. E.g.:
CD = ... % This your data in a Table array format. Column name is Infected (New Infected)
% the new infected victims>200
IN1 = (CD.Infected>200);
CD1 = CD(IN1, :);
% 100≤new infected victims≤200
IN2 = (CD.Infected>=100 & CD.Infected<=200);
CD2 = CD(IN2, :);
% new infected victims<50
IN3 = (CD.Infected<50);
CD2 = CD(IN3, :);

2 件のコメント

Ronaldo Thein
Ronaldo Thein 2021 年 6 月 5 日
ok thank you very much...Sulaymon
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 6 月 5 日
編集済み: Sulaymon Eshkabilov 2021 年 6 月 5 日
Most Welcome!

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

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

質問済み:

2021 年 6 月 5 日

編集済み:

2021 年 6 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by