Hello
The following does not work at the part where cell arrays are. I believe the "any function" does not work the way i want it to - it doesn't produce an error, but it doesn't work either. I want to check if any of the values in cell a and N (which consists of vectors).
for i = 1 : length(W)
if X(i) < 20 || X(i) > 30 || Y(i) < 50 || Y(i) > 150 ...
|| any(a{i}) < 0 || any(a{i}) > 12 ...
|| any(N{i}) < 13 || any(N{i}) > 40
X(i) = [];
Y(i) = [];
a{i} = [];
N{i} = [];
fprintf('Error in test subject %d, discarding dataline.\n',l)
end
end

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2014년 6월 25일

0 개 추천

Could it be that you meant to write
any(a{i}<0)
instead of
any(a{i})<0
likewise for the others ??
Titus

댓글 수: 1

Kenan Hoyt
Kenan Hoyt 2014년 6월 25일
편집: Kenan Hoyt 2014년 6월 25일
It works, thanks a lot! Now another problem occurs, though. In a loop 1:5, i changed the values in vectors 3 and 5 in X to 99999 and the following error occurs:
Error in test subject 3, discarding dataline.
Attempted to access X(5); index out of bounds because numel(X)=4.
Should i ask for this in a separate question? Edit: asking in a new question.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2014년 6월 25일

편집:

2014년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by