Resave a Matlab file with v7.3 option

Hello,
I have few huge files with many substructures inside. I need to partially modify the content. I'm using matfile with option "'Writable',true".
I'm getting a lot of errors because although the total file is less than 2Gb, apparently once uncompressed some array is over 2 GB:
"Warning: The file 'D:\work\capture_tool\dsp\ctt_platform\input\rawdata_toronto55_matrix7x5_70g_50taps.mat' was saved in a format that does not support partial loading. Temporarily loading variable 'Push'
into memory. To use partial loading efficiently, save MAT-files with the -v7.3 flag.
Warning: Variable 'Push' was not saved. For variables larger than 2GB use MAT-file version 7.3 or later. "
If i load and save, it adds another layer in the structure which is the name of the original variable i used to load. Therefore, my program can't access it again:
temp = load('orig.mat');
save('-v7.3','mod.mat','temp')
temp2 = load('mod.mat')
temp2 =
struct with fields:
temp: [1×1 struct]
How can i automatically resave the files with option v7.3 leaving the structure untouched?
Thanks
Riccardo

 Respuesta aceptada

Ridwan Alam
Ridwan Alam el 21 de Nov. de 2019
Editada: Ridwan Alam el 21 de Nov. de 2019
The version option goes at the end on save():
save('mod.mat','temp','-v7.3');
While loading,
temp2 = load('mod.mat');
temp2 = temp2.temp;

6 comentarios

Riccardo Micci
Riccardo Micci el 21 de Nov. de 2019
i don't think that solves the issue. Now i have special cases for the "modded" files.
Old files won't require "temp2 = temp2.temp;" but the new ones will.
So the main function will either fail with one or the other.
Ridwan Alam
Ridwan Alam el 21 de Nov. de 2019
Editada: Ridwan Alam el 21 de Nov. de 2019
First of all, which issue? the saving one or the loading one?
I guess you meant the loading one.
If you want to keep the original name, just use:
load('mod.mat') % instead of assigning it to anything
Riccardo Micci
Riccardo Micci el 21 de Nov. de 2019
The issue is in the saving. I need to maintain the file behaviour but i needed it the new file format. So i can the modify internally the single items. I can't modify the source that uses the file i.e. the loading function.
The original code was assigning it to a variable so i must still do that.
Ridwan Alam
Ridwan Alam el 21 de Nov. de 2019
Editada: Ridwan Alam el 21 de Nov. de 2019
I am not sure if this helps:
save('mod.mat','-v7.3');
I am just a bit confused here, so even if you know that the "load" is causing issue, you still can't modify the files?
I don't think the save() function adds that extra structure layer. It's the load() function, when you assign the returned value to a variable.
Riccardo Micci
Riccardo Micci el 21 de Nov. de 2019
i see what you're trying to do and actually works. The right sequence of actions is:
clear all
load('matfile.mat');
save('matfile','-v7.3');
It's a bit clumsy but makes sure the new file only includes data from the original one.
Ridwan Alam
Ridwan Alam el 21 de Nov. de 2019
Editada: Ridwan Alam el 21 de Nov. de 2019
Cool!! Glad to help!
Please accept the answer and vote if you liked the conversation!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 21 de Nov. de 2019

Editada:

el 21 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by