Read older MATFILE in the current version.
Mostrar comentarios más antiguos
Hi, I have very old matlab files. Current Matlab dose not support the old format. I have tried reading it in Python and R. Python does read it but the output data is not correct. Is there a way to read these files and retreive the data. I have attached a test file for the reference. Any help would be great!
7 comentarios
Star Strider
el 26 de Abr. de 2023
Editada: Star Strider
el 26 de Abr. de 2023
I can’t open it with load. Try it as a .txt file.
EDIT — (19:06)
To be clear, a .txt file instead of a .mat file.
Walter Roberson
el 26 de Abr. de 2023
Editada: Walter Roberson
el 26 de Abr. de 2023
Not text files. At the moment I cannot rule out v4 files
DGM
el 26 de Abr. de 2023
Shouldn't v4 files be readable?
How old is plausible given what's known of the file lineage?
Cris LaPierre
el 26 de Abr. de 2023
Do you have a guess at approximately what version of MATLAB this was created in?
dipak sanap
el 26 de Abr. de 2023
Walter Roberson
el 26 de Abr. de 2023
https://www.mathworks.com/matlabcentral/fileexchange/22675-read-vaxd-and-vaxg-files-in-r2008b-and-later
https://www.mathworks.com/matlabcentral/answers/13901-converting-vax-float-to-matlab-float
dpb
el 26 de Abr. de 2023
Table 1-8, Level 4 MAT-File Matrix Header Format
Field Description
type The type flag contains an integer whose decimal digits encode storage information. If the
integer is represented as MOPT where M is the thousands digit, O is the hundreds digit, P is the
tens digit, and T is the ones digit, then:
M indicates the numeric format of binary numbers on the machine that wrote the file. Use this
table to determine the number to use for your machine:
0 IEEE Little Endian (PC, 386, 486, DEC Risc)
1 IEEE Big Endian (Macintosh, SPARC®, Apollo, SGI, HP
9000/300, other Motorola® systems)
2 VAX D-float
3 VAX G-float
4 Cray
...
Looking at the given file (had to do this locally, couldn't seem to fopen the attachment)...
>> fn='test_read.mat';
>> fid=fopen(fn,'r');
>> type=fread(fid,1,'int4')
>> type =
3000
>> fid=fclose(fid);
That would indeed, seem to be a MATLAB 4 VAX G-float array....
There's a link to the description of .mat files V4, V5 available at https://www.mathworks.com/matlabcentral/answers/93868-is-there-documentation-on-the-structure-of-mat-files-in-matlab#answer_103219
Respuesta aceptada
Más respuestas (1)
Steven Lord
el 26 de Abr. de 2023
0 votos
I tried loading the original data using the oldest release of MATLAB I can run and was able to read it. It must have been created by a very old release (pre-v4 perhaps?). I resaved it as a newer MAT-file, attached here.
6 comentarios
dipak sanap
el 26 de Abr. de 2023
Is there a TMW service to translate old files that have been orphaned by dropping support for early releases, Steven? That would seem to be a valuable service that a 'bot could handle like the "convert pdf to Excel" services that abound.
Or, I guess presuming the file exchange submissions work, that's not too bad of a route to have to go, other than it seems that it would be a useful amenity for load or whos to let the user know what the deal is instead of just not being able to read it and quitting....Python at least did recognize it as MAT 4 and indicated it was sorry, but at least it gave useful feedback.
Not all that common any more, but when it bites it's bound to hurt a lot and most wouldn't think to try Python, I'd venture nor know to go searching FEX.
Just out of curiosity, how old was "oldest" version?
Star Strider
el 26 de Abr. de 2023
@dpb — I first used it on a PC in 1993 for my first course in linear control systems, and it may have existed before then. (The course was taught at night, after work.) In those days, it came on a series of 3½" (8.9 cm) floppies that had to be loaded sequentially, and the documentation was a library of hardcopy softcover books. I believe earlier mainframe versions existed from about 1980 onward, however I’m not certain of that. I’ve been using it in some capacity ever since.
dpb
el 26 de Abr. de 2023
Oh, yeah, I've had copy since the first Windows 3.1 release; was thinking the other day I probably shouldn't have but I cleaned out and threw out the old 3.5" floppy disc releases a while back...the PC version was released in roughly mid-80s; there's a history at the TMW site but I didn't go refresh my memory of exact dates. I think I purchased the first copy with my first PC when SAIC (thru whom I was consulting at the time) had an employee interest-free paycheck loan program. I had waited until the AT came out and bought the then-new AST Research 286 /287 coprocessor and the whole of 2MB(!) memory and a 10MB harddrive. With a 12" mono monitor, it was something around $4K in, I think, late '87/early '88 time frame. That machine still survives and, I guess the last release I loaded on it would still run, actually, although I've not booted it in years and years and years, now...dunno if it would, but couldn't bring myself to throw it out. :)
What I was really asking Steven about was what was the oldest release he could still run...
Cris LaPierre
el 27 de Abr. de 2023
I found I could open the file in R2007b, and R2008a, but not R2008b.
I couldn't launch anything earlier than that on my computer.
Steven Lord
el 27 de Abr. de 2023
Actually now that I think about it I didn't use the oldest release I believe can run on my machine (which is different from the oldest release whose files I could access.) I went as far back as release R11 (even though that's not remotely close to a supported release on my OS) because I know I can run that release with only a little difficulty.
Since I work on functions that have existed in some cases since Cleve's original MATLAB (predating MathWorks!) sometimes it's useful to perform "archaeology" to figure out when a particular behavior was introduced and that can entail reading or running code from very old releases.
Is there a TMW service to translate old files that have been orphaned by dropping support for early releases, Steven? That would seem to be a valuable service that a 'bot could handle like the "convert pdf to Excel" services that abound.
I don't know if there is such a service, though it's an interesting idea.
Categorías
Más información sobre Standard File Formats en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!