move a row from a cell to another cell

3 visualizaciones (últimos 30 días)
MUKESH KUMAR
MUKESH KUMAR el 7 de Feb. de 2018
Editada: Stephen23 el 7 de Feb. de 2018
I had a cell array Q like this
Q=cell(5,1);
Q{1,:}=[1 2 3 4;11 22 33 4;11 2 33 4];
Q{2,:}=[1 11 11 2;22 2 32 33];
Q{3,:}=[12 21 1 2;13 32 23 2;11 23 22 22;1 11 111 42;13 23 2 23];
.... and so on. now i want to move a row from Q{1,:}(1,:) into another cell like in Q{2,:} or Q{3,:} or Q{4,:} or Q{5,:} except Q{1,:} how can i do this ? thanks

Respuesta aceptada

Stephen23
Stephen23 el 7 de Feb. de 2018
Editada: Stephen23 el 7 de Feb. de 2018
Your data:
>> Q = cell(3,1);
>> Q{1} = [1,2,3,4;11,22,33,4;11,2,33,4];
>> Q{2} = [1,11,11,2;22,2,32,33];
>> Q{3} = [12,21,1,2;13,32,23,2;11,23,22,22;1,11,111,42;13,23,2,23];
MATLAB does not have a "move" operation, so you have to do this in two steps:
>> Q{2} = vertcat(Q{2},Q{1}(1,:)); % copy row from Q{1} to Q{2}
>> Q{1}(1,:) = []; % delete row from Q{1}
and checking:
>> size(Q{1})
ans =
2 4
>> size(Q{2})
ans =
3 4

Más respuestas (1)

ES
ES el 7 de Feb. de 2018
>> Q{1,:}(1,:)
ans =
1 2 3 4
>> Q{2,:}(1,:) = Q{1,:}(1,:)% Do you simply mean this?
Q =
[3x4 double]
[2x4 double]
[5x4 double]
[]
[]
>> Q{2,:}(1,:)
ans =
1 2 3 4
  1 comentario
MUKESH KUMAR
MUKESH KUMAR el 7 de Feb. de 2018
No, I want to move Q{1,:}(1,:) to Q{2,:} cell after that size of Q{2,:} will be [3*4 double] and size of Q{1,:} will be [2*4 double]

Iniciar sesión para comentar.

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by