Extracting data from a table(.mat file)

15 views (last 30 days)
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 Comment
Abhivyakti
Abhivyakti on 16 Jul 2012
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.

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 16 Jul 2012
% 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 Comments
Khan Engr
Khan Engr on 15 Jul 2020
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 on 15 Jul 2020
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 :(

Sign in to comment.

More Answers (2)

Image Analyst
Image Analyst on 16 Jul 2012
Edited: Image Analyst on 16 Jul 2012
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 on 16 Jul 2012
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.

Community Treasure Hunt

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

Start Hunting!