Jump to content
Berker

Overwriting .mat file

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

createFolder.oml

saveResults.oml

zzz.oml

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...