extract the same coloumn from multiple mtrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Matt J
2012년 10월 19일
편집: Matt J
2012년 10월 19일
If your data exists as an MxNx640 array, then it's easy
newmatrix= data(:,70,:);
newmatrix=reshape(newmatrix,M,640);
댓글 수: 5
Matt J
2012년 10월 19일
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);
추가 답변 (2개)
Razvan
2012년 10월 19일
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
Azzi Abdelmalek
2012년 10월 19일
편집: Azzi Abdelmalek
2012년 10월 19일
how are named your 640 matrix? , or do you import them each iteration
Azzi Abdelmalek
2012년 10월 19일
편집: Azzi Abdelmalek
2012년 10월 19일
M=[]
for k=1:8
s=['M=[M' sprintf([',device%d_%d(:,70)'],[k*ones(1,80);(1:80)]) ']']
eval(s)
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!