Converting a .mat file with multiple variables from v5 to v7
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Antoinette Burger
le 1 Mar 2023
Commenté : Antoinette Burger
le 2 Mar 2023
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 commentaires
Walter Roberson
le 1 Mar 2023
I would only expect that message to appear on a save under two different circumstances:
- 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.
- 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.
Réponse acceptée
Walter Roberson
le 1 Mar 2023
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)
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');
disp(b6)
disp(char(b6));
fprintf('\nv7\n');
disp(b7)
disp(char(b7));
fprintf('\nv73\n');
disp(b73)
disp(char(b73));
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 commentaires
Walter Roberson
le 2 Mar 2023
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur File Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!