필터 지우기
필터 지우기

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