Converting a .mat file with multiple variables from v5 to v7

I have a .mat file that contains variables of 120 trials of behavioural data. The file was saved in v5 format, which doesn't seem to be supported so I am trying to save it as v7 using
save('rsvp_data.mat', '*', '-v7')
using the '*' as wildcard to select all the variables instead of writing all 120 of them out.
I get the error:
Error using save
Unable to write file rsvp_data.mat: No such file or directory.
I am in the correct directory and path and all the relevant files are in the directory/path. The original file is named rsvp_data.mat. Should it be renamed to something else? I have tried saving the workspace also, but it doesn't have the 'save as' option, only 'save'.
Does anyone have any advice for me?

4 comentarios

save('rsvp_data.mat', '-v7')
could be used to store all the variables in the current workspace.
Thank you@Walter Roberson I still get the same error that the file/directory doesn't exit. It's very strange.
I would only expect that message to appear on a save under two different circumstances:
  1. the current directory in MATLAB is one that no longer exists. This would have required that the directory was deleted after the user changed to that directory.
  2. the current directory in MATLAB is set to a network drive such as Microsoft OneDrive, and the network drive is acting up. I have seen more reports of that for OneDrive in particular than for other drives such as Google Drive, but hypothetically OneDrive might perhaps just be used a lot more than the others... so I do not know if it is worse than the others or if it is just used so much more than a lower portion would still give more reports than the hypothetically worse drives.
Thank you @Walter Roberson, I appreciate your help!

Iniciar sesión para comentar.

 Respuesta aceptada

The file was saved in v5 format, which doesn't seem to be supported
Supported by what? And what are you looking at to see that it was saved in v5 rather than some later version?
test = randi([-9 9], 3, 3)
test = 3×3
4 -9 -2 -4 9 -3 -2 -2 7
save('test6.mat', '-v6')
save('test7.mat', '-v7')
save('test73.mat', '-v7.3')
fid = fopen('test6.mat', 'r'); b6 = fread(fid, [1 64], '*uint8'); fclose(fid);
fid = fopen('test7.mat', 'r'); b7 = fread(fid, [1 64], '*uint8'); fclose(fid);
fid = fopen('test73.mat', 'r'); b73 = fread(fid, [1 64], '*uint8'); fclose(fid);
fprintf('\nv6\n');
v6
disp(b6)
Columns 1 through 33 77 65 84 76 65 66 32 53 46 48 32 77 65 84 45 102 105 108 101 44 32 80 108 97 116 102 111 114 109 58 32 71 76 Columns 34 through 64 78 88 65 54 52 44 32 67 114 101 97 116 101 100 32 111 110 58 32 87 101 100 32 77 97 114 32 32 49 32 50
disp(char(b6));
MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Wed Mar 1 2
fprintf('\nv7\n');
v7
disp(b7)
Columns 1 through 33 77 65 84 76 65 66 32 53 46 48 32 77 65 84 45 102 105 108 101 44 32 80 108 97 116 102 111 114 109 58 32 71 76 Columns 34 through 64 78 88 65 54 52 44 32 67 114 101 97 116 101 100 32 111 110 58 32 87 101 100 32 77 97 114 32 32 49 32 50
disp(char(b7));
MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Wed Mar 1 2
fprintf('\nv73\n');
v73
disp(b73)
Columns 1 through 33 77 65 84 76 65 66 32 55 46 51 32 77 65 84 45 102 105 108 101 44 32 80 108 97 116 102 111 114 109 58 32 71 76 Columns 34 through 64 78 88 65 54 52 44 32 67 114 101 97 116 101 100 32 111 110 58 32 87 101 100 32 77 97 114 32 32 49 32 50
disp(char(b73));
MATLAB 7.3 MAT-file, Platform: GLNXA64, Created on: Wed Mar 1 2
As you can see, v6 and v7 files both have 'MATLAB 5.0 MAT-file' in the header. v5 v6 v7 files all use the same fundamental format -- just additional capabilities were activated in the later releases.
v7.3 files are a fundamentally different format (based on HD5F) and have a different header.

7 comentarios

Sorry @Walter Roberson, I meant supported by scipy.io loadmat. The documentation for scipy.io loadmat refers to v4, v6, v7 and v7.3, and there has been another question regarding this, with the recommendation being to resave the file in a different version.
Okay, but what software produced the files believed to be v5 files ?
Antoinette Burger
Antoinette Burger el 1 de Mzo. de 2023
Movida: Walter Roberson el 1 de Mzo. de 2023
This is the feedback in terminal when checking the file:
antbu@MacBook-Air notebooks % file /Volumes/2020_MRS_CI/RSVP_data/Epilepsy/Monitoring/2021-01-18_e0011XQ_01/rsvp_data.mat
/Volumes/2020_MRS_CI/RSVP_data/Epilepsy/Monitoring/2021-01-18_e0011XQ_01/rsvp_data.mat: Matlab v5 mat-file (little endian) version 0x100, platform MACI64, created Wed Mar 1 15:59:18 2023
The file was created by Monkeylogic, an app that runs in Matlab.
test = randi([-9 9], 3, 3)
test = 3×3
0 -9 -1 6 9 0 8 9 -8
save('test6.mat', '-v6')
save('test7.mat', '-v7')
save('test73.mat', '-v7.3')
!file test6.mat
test6.mat: Matlab v5 mat-file (little endian) version 0x0100
!file test7.mat
test7.mat: Matlab v5 mat-file (little endian) version 0x0100
!file test73.mat
test73.mat: Hierarchical Data Format (version 5) with 512 bytes user block
As I said, -v5 through -v7 all say MATLAB 5.0 file in the header, and file reports v5 for all of them, but that does not prove they were created with v5 specifically.
I understand, thank you @Walter Roberson
MAT is MATLAB’s native data format. NIMH ML uses the default MAT-file format that is set in the MATLAB Preferences.
That is, monkeylogic is just using save() without specifying a -v option to save() . And since '-v5' is not a supported option, it could not have been saved in the original unmodified MAT 5.0 format.
Thank you @walter robertson, we went with what we saw in the file description in terminal. Your explanation helps a lot to understand the file formats.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2022b

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by