Re: how to clear a variable whose name is located in a string?
- From: "joa" <joachim.vandekerckhove@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 8 Aug 2006 17:35:37 +0200
Not the nicest way, but:
Name Size Bytes Classwhos
chicken 1x3 24 double array
filename 1x7 14 char array
Grand total is 10 elements using 38 bytes
Name Size Bytes Classeval(['clear ' filename])
whos
filename 1x7 14 char array
Grand total is 7 elements using 14 bytes
hth
"Anish Patel" <iceapatel@xxxxxxxxxxx> wrote in message
news:20420268.1155048942396.JavaMail.jakarta@xxxxxxxxxxxxxxxxxxxxxxxxx
For example:
filename=input('enter name of file to load: ",'s')
% eg: user inputs 'chicken'
filename2=[filename '.txt']
load(filename2, 'ascii')
% now matlab has loaded a numeric matrix called 'chicken'
After doing stuff with the variable, I now want to clear it from memory
(since its a big file) before loading another file to analyze.
At this point I have 2 variables: [1] string variable -->
filename='chicken' and a numeric variable --> chicken=[1 2 3]
I want to clear the numeric variable 'chicken', but the name of the
variable is located in the string 'filename' (as input by the user).
I tried:
clear(filename) % only clears the string, not the numbers
clear(eval(filename)) % doesn't work either
Any ideas?
Thanks,
Anish
.
- References:
- how to clear a variable whose name is located in a string?
- From: Anish Patel
- how to clear a variable whose name is located in a string?
- Prev by Date: help with fminsearch
- Next by Date: Re: convert array to string
- Previous by thread: Re: how to clear a variable whose name is located in a string?
- Next by thread: Re: Markov Model Help
- Index(es):
Relevant Pages
|