If-statement, comparison of two vectors, both containing zero elements
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi there, I want to compare two vectors that both contain elements equal to 0 in an if statement (so if vec1 < vec2) for example. This leads Matlab to skip the whole if loop, does anyone have an idea to solve this? Both vectors have the same length
vec1 = [1 0 3 6 43 56];
vec2 = [2 9 5 0 23 43];
if vec1 < vec2
disp('it works');
else
disp('it doesnt');
end
How can I solve this?
댓글 수: 0
채택된 답변
madhan ravi
2019년 7월 30일
편집: madhan ravi
2019년 7월 30일
Wenn ich richtig verstehe, was du machen willst, dann:
vec1 = [1 0 3 6 43 56];
vec2 = [2 9 5 0 23 43];
for k = 1:numel(vec1)
if vec1(k) < vec2(k))
disp('it works');
else
disp('it doesnt');
end
end
댓글 수: 2
madhan ravi
2019년 7월 30일
Toll, ich wusste das, aber ich hab' wegen des Textes verwirrt. Viel Spaß beim Lernen.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!