I want to save values from my if statement in an array

1 回表示 (過去 30 日間)
Sam17
Sam17 2018 年 6 月 14 日
回答済み: Walter Roberson 2018 年 6 月 14 日
I am trying to save values of the peakInterval which lies in between 550 and 900 to a separate array. I don't know why this code doesn't save the values in the x array. Can you fix the problem?
x=[]
if (peakInterval >= 550) & (peakInterval<=900)
x=peakInterval
end
x(:)=[]

採用された回答

Walter Roberson
Walter Roberson 2018 年 6 月 14 日
mask = (peakInterval >= 550) & (peakInterval<=900);
x = peakInterval(mask);

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by