extract the same coloumn from multiple mtrix

4 visualizaciones (últimos 30 días)
sami
sami el 19 de Oct. de 2012
Hi! I'm new here i want to ask if there is a solution in Matlab to extract the same column number from multiple matrix. I have 640 matrix and I want to extract from each mtrix the column indexed 70 and save this column in one new matrix .I thank you in advance for your help

Respuesta aceptada

Matt J
Matt J el 19 de Oct. de 2012
Editada: Matt J el 19 de Oct. de 2012
If your data exists as an MxNx640 array, then it's easy
newmatrix= data(:,70,:);
newmatrix=reshape(newmatrix,M,640);
  5 comentarios
Matt J
Matt J el 19 de Oct. de 2012
Sigh... Well, first we'll have to undo the damage. Nothing will be fast until we do:
M=cell(8, 80);
for i=1:8
for j=1:80
M{i,j}=eval(['device' num2str(i) '_' num2str(j)]);
end
end
Now you can do as before
data=cat3(M{:});
newmatrix= data(:,70,:);
newmatrix=reshape(newmatrix,M,640);
sami
sami el 19 de Oct. de 2012
Thank you

Iniciar sesión para comentar.

Más respuestas (2)

Razvan
Razvan el 19 de Oct. de 2012
To extract column 70 from matrix M you do
C = M(:,70);
To add this column to another matrix (M2) you do
M2 = [M2, C];
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 19 de Oct. de 2012
Editada: Azzi Abdelmalek el 19 de Oct. de 2012
how are named your 640 matrix? , or do you import them each iteration
sami
sami el 19 de Oct. de 2012
the 640 matrices are 150*19 Double matrices and are named device1_1 to device1_80 device2_2 to device2_80 and so on 8 times

Iniciar sesión para comentar.


Azzi Abdelmalek
Azzi Abdelmalek el 19 de Oct. de 2012
Editada: Azzi Abdelmalek el 19 de Oct. de 2012
M=[]
for k=1:8
s=['M=[M' sprintf([',device%d_%d(:,70)'],[k*ones(1,80);(1:80)]) ']']
eval(s)
end

Categorías

Más información sobre Matrix Indexing 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!

Translated by