Extracting data from a table(.mat file)

15 次查看(过去 30 天)
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