0

Does MATLAB keep some variables after clearing?

Matlab: Free memory is lost after calling a function

My question is related to this post but some changes are there.

I have to use the output (the outputs are matrices generated, i.e. i am generating small matrices in every iteration) produced by previous large program, in my next iteration of large program, so when i am using the technique mentioned in the post, i am getting error that " Reference to a cleared variable", i need to keep some of the variables and some matrices generated. How to do that?

Sometimes the error occurs after 1 iteration only

Thanks

1
  • 1
    See here Commented Apr 5, 2013 at 6:01

1 Answer 1

1

You can clear specific variables in the workspace with:

clear myvarname

You can also clear functions that might be holding persistent variables with:

clear myfunname

So - you should work out which ones you don't want (type whos to see variables in the workspace, or in a breakpoint) and clear the ones you don't need.

Another option would be to save the ones you do want, use the clear method you mentioned, then re-load.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.