Prev: How can I compute the probability that a set has normal distributionwith zero mean
Next: rescaling for fmincon
From: Jean-Philip Dumont on 27 Jul 2010 15:06 Hi, I Have a main structure called "Results". In that structure, I have other structures that each contain different series. The series in each structure have the same name. For example, let say I have an exchange rate time serie from t=1 to T that is called S1. This serie finds itself in Results.Trend.S1. I also have the Dates, Tbill and Vol corresponding to those data (corresponding to the same dates) that find themselves in : Results.Tbill.S1 Results.Vol.S1 Results.Dates.S1 Let say I would like to delete S1 in all the structures, is there a way of doing this instead of writing four lines? Results.Trend = rmfield(Results.Trend, 'S1') Results.TBill = rmfield(Results.TBill, 'S1') Results.Vol = rmfield(Results.Vol, 'S1') Results.Dates = rmfield(Results.Dates, 'S1') Thank you very much! JP
From: us on 27 Jul 2010 15:28 "Jean-Philip Dumont" <jean-philip.dumont(a)hec.ca> wrote in message <i2namt$oeg$1(a)fred.mathworks.com>... > Hi, > > I Have a main structure called "Results". In that structure, I have other structures that each contain different series. The series in each structure have the same name. > > For example, let say I have an exchange rate time serie from t=1 to T that is called S1. This serie finds itself in Results.Trend.S1. > I also have the Dates, Tbill and Vol corresponding to those data (corresponding to the same dates) that find themselves in : > > Results.Tbill.S1 > Results.Vol.S1 > Results.Dates.S1 > > Let say I would like to delete S1 in all the structures, is there a way of doing this instead of writing four lines? > > Results.Trend = rmfield(Results.Trend, 'S1') > Results.TBill = rmfield(Results.TBill, 'S1') > Results.Vol = rmfield(Results.Vol, 'S1') > Results.Dates = rmfield(Results.Dates, 'S1') > > Thank you very much! > > JP one of the solutions % the data clear a; % <- save old stuff... a.f1.sf1=1; a.f1.sf2=2; a.f2.sf1=3; a.f2.sf2=4; % the engine fn=fieldnames(a); for cf=fn(:).' a.(cf{:})=rmfield(a.(cf{:}),'sf1') end % the result a.f1 % ans = sf2: 2 us
From: Jean-Philip Dumont on 27 Jul 2010 15:46
"us " <us(a)neurol.unizh.ch> wrote in message <i2nc0m$knc$1(a)fred.mathworks.com>... > "Jean-Philip Dumont" <jean-philip.dumont(a)hec.ca> wrote in message <i2namt$oeg$1(a)fred.mathworks.com>... > > Hi, > > > > I Have a main structure called "Results". In that structure, I have other structures that each contain different series. The series in each structure have the same name. > > > > For example, let say I have an exchange rate time serie from t=1 to T that is called S1. This serie finds itself in Results.Trend.S1. > > I also have the Dates, Tbill and Vol corresponding to those data (corresponding to the same dates) that find themselves in : > > > > Results.Tbill.S1 > > Results.Vol.S1 > > Results.Dates.S1 > > > > Let say I would like to delete S1 in all the structures, is there a way of doing this instead of writing four lines? > > > > Results.Trend = rmfield(Results.Trend, 'S1') > > Results.TBill = rmfield(Results.TBill, 'S1') > > Results.Vol = rmfield(Results.Vol, 'S1') > > Results.Dates = rmfield(Results.Dates, 'S1') > > > > Thank you very much! > > > > JP > > one of the solutions > > % the data > clear a; % <- save old stuff... > a.f1.sf1=1; > a.f1.sf2=2; > a.f2.sf1=3; > a.f2.sf2=4; > % the engine > fn=fieldnames(a); > for cf=fn(:).' > a.(cf{:})=rmfield(a.(cf{:}),'sf1') > end > % the result > a.f1 > % ans = sf2: 2 > > us Nice! Thank you! |