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

13 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 1 Mar 2023
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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 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)
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 Comments
Walter Roberson
Walter Roberson on 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.
Antoinette Burger
Antoinette Burger on 2 Mar 2023
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.

Sign in to comment.

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!