Multiple values in the if-expression
40 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Star Strider
2014-12-20
Your program is breaking on i_testen == 1 because at the end of the if statement conditions you have:
(i_testen <= 4)
that will cause the if condition to be true for i_testen == 1.
更多回答(1 个)
Guillaume
2014-12-20
To compare values together use ==, the equality comparison operator, not = which is the assignment operator
3 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!