4
votes

As I am running out of licenses I am using both Matlab and Octave and as long as I keep things simple I haven't had any trouble.

I recently started using .mat files to decrease my amount of single files.

When I do everything in Matlab it works just fine but when I use 'save' in Octave it saves the file as ASCII and it looks somewhat like this at the beginning and has multiple matrixes in it and so multiple headers.

# Created by Octave 3.6.4, Mon Feb 24 21:34:39 2014 CET <***@****>
# name: C
# type: matrix
# rows: 10000
# columns: 10
 79 79 79 79 79 79 79 79 79 79
 74 115 87 55 101 46 83 92 113 61
 69 142 128 48 160 45 87 113 114 71
 84 107 145 62 245 78 69 88 149 78
 120 73 148 32 299 114 57 79 137 76

This is fine but Matlab refuses to read the file. Neither with 'load' and '-ASCII' nor with importdata. (Warning: File contains uninterpretable data....)

Is there anything I can do? Octave loads the files just fine with 'load'.

Thanks!!

1
Have you tried with -V4, -V6 or -V7 options to save()?juliohm
Thank you! I missed this option! works fine with Matlab 8weelux

1 Answers

2
votes

In Octave save as "-ascii" or as matlab binary format v4, v6, v7

octave:1> a = rand(3, 3)
a =
   0.086093   0.541999   0.889222
   0.029643   0.633532   0.762954
   0.544787   0.150573   0.927285
octave:2> save ("-ascii", "yourfile.asc")
octave:3> save ("-v7", "yourfile.mat")

back in matlab do

>> b = load ('yourfile.asc')

b =

    0.0861    0.5420    0.8892
    0.0296    0.6335    0.7630
    0.5448    0.1506    0.9273

or

>> load ('yourfile.mat')
>> a

a =

    0.0861    0.5420    0.8892
    0.0296    0.6335    0.7630
    0.5448    0.1506    0.9273