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

조회 수: 2 (최근 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 CenterFile Exchange에서 Fluid Dynamics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by