Extracting data from a table(.mat file)

조회 수: 15 (최근 30일)
Abhivyakti
Abhivyakti 2012년 7월 16일
댓글: Walter Roberson 2020년 7월 15일
I have a .mat file which consist of a table( size- 19x3659). I need to extract data from it in the following pattern. Column 1-3 (Then after a gap of 128) Column 129-131 column 385-387....and so on. All the rows are to be considered.
I have no clue about this. New to MATLAB. Any help would be appreciated.
  댓글 수: 1
Abhivyakti
Abhivyakti 2012년 7월 16일
P.s : I need the extracted data in the form of a table , the way it was earlier with the same rows and selected columns.

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 7월 16일
% let us take the random matrix a, 19x3659
a=rand(19,3659);
[n,m]=size(a);b=1:m;
ind=find(and(mod(b,128)<4,mod(b,128)>0))
%check your indices 1-3 129-131 on ind, the extracted matrix result is:
result=a(:,ind)
  댓글 수: 3
Khan Engr
Khan Engr 2020년 7월 15일
Hi Azzi Abdelmalek and Abhivyakti, I read this solution, I think my problem is similar, could you please help in my question posted today that you can read on the link
Thanks
Walter Roberson
Walter Roberson 2020년 7월 15일
data = cat(1, image_patches,labels);
That code is overwriting all of data each iteration.
It looks to me as if data will not be a vector, but I do not seem to be able to locate any hellopatches() function so I cannot tell what shape it will be. As you are not doing imresize() I also cannot be sure that all of the images are the same size, so I cannot be sure that data will be the same size for each iteration. Under the circumstances you should be considering saving into a cell array.
Note: please do not post the same query multiple times. I found at least 3 copies of your query :(

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Image Analyst
Image Analyst 2012년 7월 16일
편집: Image Analyst 2012년 7월 16일
Something like this (untested):
% Load mat file.
s = load(fullMatFileName);
% Extract the table. Hopefully it's a numerical array called theTable.
theTable = s.theTable;
% Get columns to extract out
[rows columns] = size(theTable);
columnsToExtract = [];
for c = 1 : 128 : (columns-3)
% Add these 3 columns.
columnsToExtract = [columnsToExtract , c, c+1, c+2];
end
% Create the new table.
newTable = theTable(:, columnsToExtract);

Albert Yam
Albert Yam 2012년 7월 16일
original = magic(10);
In the form of, selected = original(rows,columns);
selected = original([1:2 5 8:9] , [3 5:7])
Which is rows 1-2,5,8-9 and columns 3,5-7 play around with it. Good luck.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by