Create a binary array with any dimension
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Guilherme Preisser
am 10 Dez. 2018
Kommentiert: Adam Danz
am 10 Dez. 2018
Hello,
I need to save a .mat variable that has 226 rows and 301 columns in a .bin binary file. What is the way to do this?
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 10 Dez. 2018
5 Kommentare
Adam Danz
am 10 Dez. 2018
As Stephen mentioned, this is how a binary file works. Here's an example.
Here we create a matrix and save it to a binary file.
fileID = fopen('MyMatrix.bin','w');
myMat = magic(3)
myMat =
myMat =
8 1 6
3 5 7
4 9 2
fwrite(fileID,myMat);
fclose(fileID);
And now we read it back into matlab and see that it's a columnar vector.
fileID = fopen('MyMatrix.bin');
myMat = fread(fileID)
myMat =
8
3
4
1
5
9
6
7
2
If you know what size the matrix should be, use reshape.
myMat = reshape(myMat, 3,3)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!