Extracting data from .mat file

1 view (last 30 days)
Usman  Ali
Usman Ali on 28 Nov 2012
Hi everyone, I have received a *.mat file from my supervisor that contains 4 tables. every table is constructed on hourly based data from a power generator, 24 hours a day and 365 days a year. so it (24*365)= 8760x1 table. that the properties of the table ''Time vector characteristics
Length 8760
Start date 01-Jan-2006 01:00:00
End date 01-Jan-2007 00:00:00
''
I need to extract data from the table in such form that I re-arrange it into 365x24 matrix so that every row show data for 1 day with 24 hours.

Accepted Answer

Mitch Martelli
Mitch Martelli on 28 Nov 2012
Sorry i dont understand well your question
to extract the data you can try to use getEntry, documentation are reported in the link below :
Moreover if i understand well your aim reshape(xxx,365,24) dont give you what you want.
B = reshape(xxx,24,365);
B=B';
  1 Comment
Usman  Ali
Usman Ali on 6 Dec 2012
Actually I had a time series data with time stamp and data in the array that's why reshape is not working. NOw I extracted the data and time seperately from the file and save to another variable. and then applied the reshape, it works now.

Sign in to comment.

More Answers (2)

Mitch Martelli
Mitch Martelli on 28 Nov 2012
Hi, You can use the reshape function.
Example :
data=rand(8760,1)
B = reshape(data,24,365);
B=B';
Regards
M1tC4

Image Analyst
Image Analyst on 28 Nov 2012
What is stored in the mat file? Is it a structure with a cell array with 4 cells, and inside each cell is another cell array that is the table? So basically in other words there are 4 tables. And each table is an (N rows) by (3 columns) cell array where each of those cells contains a string? Because that's what you're showing. Can you do this and tell us what shows up in the command window:
storedStructure = load(yourMatFileName);
whos storedStructure
storedStructure
  1 Comment
Usman  Ali
Usman Ali on 28 Nov 2012
Sorry I am newbie to matlab so not clear about structures etc. the .mat file contains 4 arrays (tables). if I check the size of each array it show (8760x1), but when i double click on the table, shows format like times series. u can see that in attached picture. https://www.dropbox.com/s/7dllq5alm0zuffr/test.jpg
I would like to extract data from last table zr513..
I tried it with reshape(zr513,365,24); but it give this error, 'To RESHAPE the number of elements must not change'

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!