Manipulation of matrices stored as { }

2 visualizaciones (últimos 30 días)
Emerson De Souza
Emerson De Souza el 2 de Abr. de 2011
let
n=[1:1:9;1:1:9];
M=n';
I used the following loop to extract parts of M to mk matrices
for k=1:3;
l=((k-1)*3)+1;
m=2+l;
mk{k}=M(l:m,1:end);
end;
In a following step I want to construct a new matrix Mnew by concatenating each mk matrix horizontally.
the wished result is:
Mnew=
1 1 4 4 7 7
2 2 5 5 8 8
3 3 6 6 9 9
To obtain Mnew I wrote:
Mnew=[mk{1,1} mk{1,2} mk{1,3}];
Question: How do I have to write to automatize the
last line above using the index k instead of
the numbers that I typed manually?
Thank you
Emerson

Respuesta aceptada

Matt Fig
Matt Fig el 2 de Abr. de 2011
It looks like you could use REPMAT and/or EXPAND.
  1 comentario
Emerson De Souza
Emerson De Souza el 5 de Abr. de 2011
Hi Matt Fig,
thank you for your suggestion.
On the other hand, I solved
the problem with
Mnew=[mk{1:3}] or
Mnew=[mk{}]
But I appreciate your attention
and intention to help.
I wish you a nice day
Emerson

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by