필터 지우기
필터 지우기

For loop inside for loop

조회 수: 8 (최근 30일)
Isma_gp
Isma_gp 2017년 8월 15일
댓글: Adam 2017년 8월 15일
Hi, I have the following function that I am using with a single rho(1x654545) -attached. The result gives me the single peaks(1x1023). I would like to modify the script so that I can use as input rho(4x654545) and end up with the result peaks(4x1023).
Can I get some help? Thanks
x = diff(sign(rho));
indx = find(x>0);
for jj=2:length(indx);
tmp = rho(indx(jj-1):(indx(jj)));
test = dt*(indx(jj)-indx(jj-1));
peaks(jj) = max(tmp);
end
  댓글 수: 4
Isma_gp
Isma_gp 2017년 8월 15일
Yes, that is true. The number of values >0 could vary.
Adam
Adam 2017년 8월 15일
In that case you'd have to use a cell array or a 2d numeric array with enough rows for the case with most peaks and leave NaNs in the extra rows for the other columns.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by