How to create an interval for an if statement?

5 ビュー (過去 30 日間)
Wolfgang McCormack
Wolfgang McCormack 2021 年 3 月 11 日
コメント済み: Cris LaPierre 2021 年 3 月 12 日
Hi all,
How can I say if q equals to 5 or 10 or 15 or ..... then
if q == 5:5:200 does not work.

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 3 月 11 日
if ismember(q,5:5:200)
  2 件のコメント
Wolfgang McCormack
Wolfgang McCormack 2021 年 3 月 12 日
@Cris LaPierre Thank you so much, Cris! I have a question, let's say I have an annual hourly time table. I want to muliply only the values for 8 AM to 8 PM of each day by a multiplier like 5 in two quarters of the year. Is it possible to get it done using this? I have seen other answers on the forum but they take longer so I was thinking this might help as well to that case.
Cris LaPierre
Cris LaPierre 2021 年 3 月 12 日
I wouldn't use this approach for that. There are other functions I would point out to you.
Extract Components by Time Unit (from this page)
Combine these with >= and <= to find the indices that meet your criteria.
Perhaps some of the ideas presented in this answer will help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by