Matt Jolley
Matt Jolley

Reputation: 3

Matlab Table separation at variable

I am dealing with large datasets imported from Excel which I have put into a matlab table, with three columns 'title' 'x' 'y' the data is in a table of 49440x3. The 'x' column data increases from 0.25 at increments of 0.25 until it reaches 154.5 then goes back to 0.25 and continues in this loop. I would like to separate the data into separate tables each starting at 0.25 and finishing at 154.5 with the associated 'title' and 'y'. However I am struggling as my knowledge of Matlab is basic.

vars={'title','x','y'};
for    rows=leafdata.x>0 & leafdata.x<154.5;
       T=leafdata(rows,vars)
       if        leafdata.x==154.5
       T=T+1
       end
end

Any help would be great

Upvotes: 0

Views: 95

Answers (1)

Joe Dobson
Joe Dobson

Reputation: 26

You can use xlsread to read in data. It might give you options of the cells to read in (check MATLAB help)

This might need some work, but I don't have Matlab or the file to test here.

lengthData=length(0:.25:154.5); %length of data

j=1
for k=1:lengthData:max(size(leafdata)) % step of lengthData until data ends
   output(j)=leafdata(k:k+lengthData,1:3); % A cell array 
j=j+1;
end

% This gives a number of different (tables) martices 3 columns by lengthData rows.

Upvotes: 1

Related Questions