Info

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

Matlab giving different results sometimes as a row vector and sometimes as a column vector

1 Ansicht (letzte 30 Tage)
Moved an entire for loop 1. outside of another for loop 2. When for loop 1 was inside, my code would sometimes giving a row vector for find instead of column vector. Happens randomly. I have sorted it out now as mentioned above but would like to know why this was happening.
  2 Kommentare
Anindya Ghosh
Anindya Ghosh am 22 Sep. 2020
loop 1
for K = 1:human_count
hr_pool = find(h_dist(:,K) <= 2);
[hr_pool_ro, hr_pool_ho] = find(h_dist <= 2);
h_interaction = 0; % Human to robot nodes
if ~isempty(hr_pool)
h_interaction = h_interaction + length(hr_pool);
hr_int(iter,K) = h_interaction;
obs_am = [hr_pool_ho,hr_pool_ro];
pp{K,:} = obs_am(find(obs_am(:,1) == K)',2);
obs{K,iter}.robots = pp{K,1}';
elseif isempty(hr_pool)
obs{K,iter}.robots = 0;
end
end
loop 2
for i = 1:robot_count
end

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by