Jump to content

save and regexp

Recommended Posts



I am trying to apply a script in Compose 2017.3, which eliminates some of the variables in the workspace when saving them as a .mat file. In order to test the issue, please load the variables in the attached .mat file in the workspace. 


When you load the attached .mat file, many variables will be available in the workspace. I would like to save these variables in another .mat file called 'berker4.mat', but I would like to eliminate 'savePath' and 'output_file' variables. In Matlab 2016a, I am using the following command:


save('berker4.mat', '-regexp', '^(?!(savePath|output_file)$).', '-v7.3');


This command eliminates the variables I mentioned. When I use the same command in Compose 2017.3, 'berker4.mat' ends up empty. I noticed that 'regexp' is available in Compose. Should I parameterize the variables to be omitted in a different way?


I appreciate if you can help me.


Thank you

Berker Bilgin


Share this post

Link to post
Share on other sites

Hello Berker,

         The expression ^(?!(savePath|output_file)$). is not currently supported in Compose. If you do not require to do any kind of operations on the loaded data, you can use the following code to create the new mat file (I agree that this is not a good solution to your problem) . Another way of solving this issue is if you write the imported data into a file once after loading the berker3.mat, you can later reuse. In this case you can use clear 'variable_name' once after the file write operation.



clear savePath;

clear output_file


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.

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...