필터 지우기
필터 지우기

Why I don't get any results from this code?

조회 수: 1 (최근 30일)
Konstantinos
Konstantinos 2016년 5월 18일
댓글: Walter Roberson 2016년 5월 20일
I run the following code:
for ii = length(pks4) %repeat the following process as many times as the pks4 points are
for k2 = (pks4(ii):xfb(end)); % for all k2 that belong between pks4 and the end of index
first2(ii) = k2(k2>xfb2); %find all k2 such that k2 is greater than xfb2
if ~isempty(first2)
first2 = first2(1); % store the first number (first2) which is greater than xfb2
else
disp('No value of k2 is greater than xfb2.')
end
distS(ii) = size(pks4(ii):first2(ii)); % distance between each pks4 and first2 points
mean_distS = mean(numPointsS(ii)); % mean distS
Send = locs_SwaveB*mean_distS; %location of S point
end
end
but in the end I get neither an error message nor any results. What's wrong with this code? And why Matlab doesn't give any error messages?
Thanks in advance for any help.

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 19일
The first length(pks4) entries in pks4 might all be greater than xfb(end) so the inner loop might never execute.
Caution: you have
first2(ii) = k2(k2>xfb2); %find all k2 such that k2 is greater than xfb2
Your comment implies there might be multiple k2 entries that fit the criteria, so the right hand side might be a vector, but you are trying to assign it into location that only fits a scalar.
  댓글 수: 4
Konstantinos
Konstantinos 2016년 5월 19일
What's the point of the breakpoint? I tried it and didn't see anything useful after the displays.
Walter Roberson
Walter Roberson 2016년 5월 20일
If you show us the output then we might be able to figure out why the loop is not working.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by