save and regexp
Hello,
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
Answers
-
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.
load('berker3.mat')
clear savePath;
clear output_file
save('berker4.mat')
0