Multiple values in the if-expression
이전 댓글 표시
My data-file is a (5x5) matrix. Each cell is a struct. In this struct there is 1 datafile (and other files like 'columnsheaders'). I have created a for-loop for 5 measurements en 5 subjects. So I tried to create an 'if-expression' to say that if specific values of that matrix are met, the program should break. But it gives the following error: "The expression to the left of the equals sign is not a valid target for an assignment."
if ((i_testen = 4) & (welke_pp = 1)) | ((i_testen = 4) & (welke_pp = 3)) | ((i_testen = 4) & (welke_pp) = 4) | ((i_testen) = 4 & (welke_pp = 5)) | (i_testen <= 4)
break
RASI = data_sts(welke_pp,i_testen).VideoSignals(:, strcmp('RASI', data_sts(welke_pp,i_testen).VideoSignals_headers));
XY(2,1) = max(RASI)
XY(1,1) = 0;
Begin_Eind_sts.Begin(i_testen) = abs(XY(2,2));
Begin_Eind_sts.Eind(i_testen) = abs(XY(1,2));
close all
end
채택된 답변
추가 답변 (1개)
Guillaume
2014년 12월 20일
1 개 추천
To compare values together use ==, the equality comparison operator, not = which is the assignment operator
댓글 수: 3
Guillaume
2014년 12월 20일
Sam's comment copied here: I did what you said. But know I've got the problem that the program breaks when the values for i_testen = 1 and welke_pp = 1... It should not break when these variables have these values. The program should only break when the variables i_testen and welke_pp have the values I have specified behind the if-expression... Help?
if ... | ... | ... | ... | (i_testen <= 4)
break
end
The last part of your if is OR i_testen <= 4 which is true for any value of welke_pp and any i_testen smaller than or equal to 4.
Amir Semnani
2021년 3월 19일
Thanks
카테고리
도움말 센터 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!