Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

to have a mobil matrix ...

1 Ansicht (letzte 30 Tage)
Alexandre Williot
Alexandre Williot am 29 Jul. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

Walter Roberson
Walter Roberson am 29 Jul. 2015
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()

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by