Overwriting .mat file

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hello,

 

I am trying to overwrite a .mat file. I created a sample script to explain the issue. Please see it below. I create a .mat file called bb.mat with three variables. Then I load the file. I assign new values to the same variable and use the save function to overwrite bb.mat. I don't receive any error. But when I load the bb.mat file, it still has the old values. I also noticed that, I cannot delete the bb.mat file. I receive a warning saying that the file was used by Compose. Could you please let me know how I can overwrite a .mat file?

 

clear all;
close all;
clc;

A=10; B=20; C=30;
save('bb.mat', '-v7.3');

clear all;
close all;
clc;

load('bb.mat');

A=25;    B=17;    C=0;
save('bb.mat', '-v7.3');

clear all;
close all;
clc;

load('bb.mat');

 

Thank you

Berker

Tagged:

Answers

  • manoj kandukuri
    manoj kandukuri
    Altair Employee
    edited February 2021

    Hi Berker,

    I couldnt able to reproduce it. if you see below, when i loaded new updated bb.mat, i could see the updated values. And also i could delete the bb.mat. 

     

    are you overwriting the variables with same variable Type? ex: overwriting Strings with strings or Numbers with numbers? 

     

    image.png.56167daf1236b56a95e011373ca95065.png

     

    Thanks,

    Manoj

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2020

    Hi Manoj,

     

    Thank you for your response. I created another case to better explain how the issue happens. I also recorded a video to show it. 

     

    You will find three .oml files. I use the same files in the video. I changed the array to be saved using zzz.oml. I have two other functions. The first one creates a folder to save the .mat file. The other one saves the variables in the workspace. You only need to run zzz.oml. After it is executed, please go to the folder where the .mat file is saved. Using 'load' in the command window, please upload the variables saved in the .mat file to the workspace. Please change the variable a few times and see whether .mat file is updated. 

     

    As you will see in the video, .mat file is not updated in my case. It works when I restart Compose. While this issues is happening and compose is running, I cannot delete the .mat file. I get a warning saying that Compose is using the file. 

     

    Please let me know if you need more details. 

     

    Thank you

    Berker

    Unable to find an attachment - read this blog

  • Matthieu Pupat
    Matthieu Pupat
    Altair Employee
    edited June 2018

    Thanks. I could reproduce your issue and will report it to our development team.

     

    Please note that as a workaround you can save to version 5 to avoid this issue:

     

     save(zzz,'-v5');