0
votes

I generated and saved large number of data files using Octave, and now I need to open them in MATLAB as part of analyzing them. MATLAB spits out this error.

Error using load
Unable to read MAT-file
[file path]/PhPar_40.mat: not a binary MAT-file.
Try LOAD -ASCII to read as text.

Trying its suggestion of load -ASCII then gives this error.

Error using load
Number of columns on line 2 of ASCII file
[filepath]/PhPar_40.mat must be the same as previous lines.

I (now) understand that Octave is capable of saving in a MATLAB readable format, but re-creating these data files would take an inordinate amount of time and really isn't an option. Is there a way to get MATLAB to read these files?

1
Please share the command you used to save the file in octave.Nick J

1 Answers

1
votes

MATLAB can't open these files because these are not saved by octave properly. Try saving them in octave by following command:

save -mat7-binary '[filepath]/PhPar_40.mat' 'm'

If you have large number of files, you can place all files in folder and then run an iterator to read all load and save in correct format automatically. This iterator will look like:

file = dir('[filepath_read]/*.mat'); 
index = 1;   
while (index==length(file)+1)
   m = load('file(index).name')
   save -mat7-binary strcat("[filepath_write]/", file(index).name, ".mat") 'm';
   index = index+1;
   pause(1);
endwhile

Once you have all the files converted to right format, load them in MATLAB. I hope it will solve your problem