-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Hi!
I was looking at how objects are stored in MAT files, and came across this repository and your explanation in MatFileHandler/objects.md. When trying to replicate, I observed some small differences in the object metadata.
Some general differences I observed:
- Instead of 6 offsets, there are 8 offsets in the list.
- The
fieldContentsIDin Region 4 is numbered starting from 0. - Region 3 has a slightly different structure as follows:
(classID, 0, 0, X, Y, objectID). I'll get into what X and Y are doing below
Some differences for string class:
- Region 3 had a slightly different structure. As expected, it was a block of six 32-bit integers, one block for each object with data as
(classID, 0, 0, X, 0, objectID).Xhere I will call asstringObjectID, as it started with1and incremented for eachstringobject in the file. On the contrary, for user defined classesXis set to0. Instead, the fifth field (Yas mentioned earlier) is set starting from1and incrementing for every user-defined class in the file. I also tried withdatetimewhich was using theYfield. My guess is these two fields are some type of internal identifiers for certain categories of objects. - Region 2 was always empty for user defined classes. However, for
string, Region 2 was present, and structured exactly the same as Region 4 would be, i.e., three 32-bit integers with the format(fieldID, 1, fieldContentsID). Only one field for each string object is present. No String related data was present in Region 4. In some examples,fieldIDwas set to5, and in others it was set to1. Need to take up a few more examples for this. - The
fieldContentscell for strings was interesting. The array flag for this was set asmxUINT64_CLASSwith dimensions[1, (5+k)], wherekdepends on the length of the string. The first four 64-bit integers was set as[1,2,1,1], and the fifth integer specified the number of characters in the string. The nextkcolumns contained the actual string contents, which is null terminated and padded to 8-byte blocks. However, the content was stored as UTF-16 characters within these 64-bit columns. Hence, each column essentially stores 4 characters.
I was looking for some help to decode what's happening with strings here, or if there's something else I could be missing. I'm looking to incorporate more objects/examples to help break this down.
The input data I used:
astring1 = "Hello!"
dt = datetime('today')
obj3 = myclass(30)
obj6 = myclass(myclass(5))
stringVar2 = "Goodbye!"
% myclass is defined with 3 properties - message, num, aeroplanes
% myclass.message is set to the input argumentReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels