adding rows somewhere in the array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi all,
I record the location of an object in 2D-screen in this format:
LOCATION = [x, y, time(cpu time), frame number];
I would like to use the frame number in future analysis as an index. However sometime I notice that the frame numbers are skipped and nunot recorded. I mean when I calculate the diff(frame_num) I get ans>1.
I thought I could resolve this issue by finding the location of those frame numbers that missed. then produce frame numbers and replicate the corresponding row values from what I have in the vector.
ex. frame_num = [1;2;3; 6;7;8; 15];
I find that I have no frame numbers between 3 and 6, and also between 8 and 15;
i want to create frame_num2 = [1; 2;3;4;5;6;7;8;9;10;11;12;13;14;15];
then for those frame numbers that I create I copy the corresponding values that I have. i.e. i copy the row of frame_number 3; for newly created frame_numbers 4 and 5.
Is there a way in matlab to find all the skipped frame numbers at once?
any idea?!
Thanks
0 comentarios
Respuesta aceptada
Brian B
el 4 de Mzo. de 2013
Then, when you want to build the complete LOCATION matrix, you can do something like
LOCATION2 = zeros(15, 4);
LOCATION2(:,1) = 1:15;
LOCATION2(LOCATION(:,1),:) = LOCATION;
to put the known values into the new matrix. Then you just have to fill in the other parts of the inserted rows.
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!