How for loop Store all average values in single values
Mostrar comentarios más antiguos
I have to store single average value from input 15 frames video file? below code i have tried but i cannot get any idea ?
if true
% code
k1_stored = zeros(1,nFrames);
for k=1:nFrames
avg= mean([X;Y]); %here x and y are array coordinates values .
k1_stored(round(avg)) = round(avg);
end
end
resultant = k1_stored(k1_stored~=0);
disp(resultant);
output: Columns 1 through 13
23 26 28 29 30 31 32 33 34 35 36 37 38
Columns 14 through 26
39 40 41 51 52 53 54 55 57 58 60 62 64
Columns 27 through 39
69 70 72 73 75 76 77 78 79 81 82 83 84
Columns 40 through 42
86 91 92
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 21 de En. de 2014
k1_stored(k) = round(avg);
6 comentarios
SAMEER ahamed
el 21 de En. de 2014
Walter Roberson
el 21 de En. de 2014
Then you are not calculating a single average value. Your X and your Y have multiple columns. You need to define what you want to have happen.
SAMEER ahamed
el 21 de En. de 2014
Editada: Walter Roberson
el 21 de En. de 2014
Walter Roberson
el 21 de En. de 2014
k1_stored(k,:) = avg;
SAMEER ahamed
el 22 de En. de 2014
Walter Roberson
el 22 de En. de 2014
Okay, so for the moment use
k1_stored{k} = avg;
notice the curly bracket instead of round bracket.
After the loop you could try
cell2mat(k1_stored)
if you get an error in doing that then there was some "avg" that was not the same length as the others.
Categorías
Más información sobre Video Formats and Interfaces en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!