Deleted variables reappearing in workspace.

7 views (last 30 days)
Pw
Pw on 5 Mar 2014
Commented: Pw on 5 Mar 2014
I am running a script with all the variables defined either in the script or in the base workspace. I have changed the names of some of the variables over time to be more concise. After these changes I have saved the workspace as well as all the scripts and functions I have been using. However, when I run one script in particular the old variables keep reappearing in the workspace and are being used by some of the other scripts. I have checked to make sure all names match the variables I want to use plus I have used clear, clearvars, and clearvars -global but they still keep reappearing. I have also tried to rerun my process from the beginning to try and eliminate residual variables. I have even tried to restart MATLAB and my computer to no avail.
Does anyone know of this issue and how to remedy it?
I can add the code here but I do not think it will be of much help. My problem is more with 'non-existing' variables popping up then the code itself. However, if someone thinks it will help I will gladly post it.
Thank you.

Answers (1)

per isakson
per isakson on 5 Mar 2014
Seriously, using functions instead of scripts is a large part of the remedy.
  1 Comment
Pw
Pw on 5 Mar 2014
You're totally right. However, this particular project calls for both and I thought maybe I had declared something global without realizing it. Turns out I was just tired and failed to see residual variables in the workspace when I was trying to save one in particular. Rookie mistake.
Thanks for the advice!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!