フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

to have a mobil matrix ...

1 回表示 (過去 30 日間)
Alexandre Williot
Alexandre Williot 2015 年 7 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello, this is a part of my script and I have a problem with matrix size. I need only position 30 to 48 of 'val_curX_centre' but sometimes it's possible that there is value with -1 that I have removed before. I think it's the reason why I have a matrix size problem but I don't know how have something like a mobil matrix size which could adapt with this script at every loop...
for nn = 1:length(Val_CurX_centre)
if abs(Val_CurX_centre(30:48,1)) > dis_th2 || abs(Val_CurY_centre(30:48,1)) > dis_th2
code_cur(nn,1) = 999;
else
if abs(Val_CurX_centre(30:48,1)) < dis_th && abs(Val_CurY_centre(30:48,1)) < dis_th
code_cur(nn,1) = 1;
else
code_cur(nn,1) = 0;%PAS DE SACCADE!!!!
end
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 7 月 29 日
You are extracting a vector and manipulating it, on both sides of the || . That would cause an error of
Operands to the || and && operators must be convertible to logical scalar values.
You would need to be using | instead of ||
You would then be testing a vector of logical values. When you do that test, "if" considers the result to be true only if all members of the vector are true, equivalent to all() around the vector. But usually people who code vector tests without specifically using all() have not realized that they are making a vector test and often what they want is for the condition to be true if any of the elements are true. To achieve that, wrap the logical test with any()

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by