From: Anthony Vescio on 15 Apr 2010 20:57 Good day, I have a list of string ids that look like this: 'Test001' 'Test002' 'Test003' 'Test004' 'Test005' ... I need to iterate through this list and delete a stringID based on a user request. I know that I will have to use a loop, but I'm not sure which function to use to delete a stringID example: Test003. Then I place the rest of the strings back in my .mat file like this: Test001,Test002,Test004,Test005, ... Below is the code I'm using to make this string list: function StringList=savedStringList(uid) % Returns cells of saved scenario list strings % if none, returns StringList{1} = {''} Slist = strcat(dataPath,'StringList.mat'); load(Slist); x=Var; N = size(x.list); for i=1:N(2) if strcmp(uid,x.list(i).id) sString=x.list(i).savedString; end end N=0; % No. of saved string IDs StringList{1}=''; while ~strcmp(sString,'') [tk, sString] = strtok(sString,','); if ~strcmp(sString,'') N=N+1; StringList{N}=tk; end end end Thank you for your time and have a wonderul day.
From: Ashish Uthama on 16 Apr 2010 09:54 On Thu, 15 Apr 2010 21:57:04 -0300, Anthony Vescio <avescio(a)dsci.com> wrote: > Good day, > > I have a list of string ids that look like this: > > 'Test001' 'Test002' 'Test003' 'Test004' 'Test005' ... > I need to iterate through this list and delete a stringID based on a > user request. I know that I will have to use a loop, but I'm not sure > which function to use to delete a stringID example: Test003. > > Then I place the rest of the strings back in my .mat file like this: > > Test001,Test002,Test004,Test005, ... > http://www.mathworks.com/support/ search for 'delete element' second link: http://www.mathworks.com/access/helpdesk/help/techdoc/math/f1-85766.html This should give you a hint to try: >> s={'one','two','three'} s = 'one' 'two' 'three' >> s(strcmp(s,'two')) =[] s = 'one' 'three'
From: Anthony Vescio on 16 Apr 2010 11:27 Thank you ... I appreciate the links as well. Anthony
|
Pages: 1 Prev: Multiple object tracking Next: Help request: Image segmentation loop |