From: Alex Eptas on 25 Jul 2010 13:33 Hi Rune Sorry if you think i am wining, i am a very basic user, obviously things like this are very easy to you. When i try the specific example you have it works find. However when i try to use it to get a list of stocks or dates for the entire data set it does not work; rootDir = 'C:\Desktop\Dissertation Data\lseTickBins\'; tmp = dir([rootDir '*.csv']); % Note with the csv files you need '*.csv' NOT '*.*.csv' fnames = char({tmp.name}'); clear tmp; % fine up to here uscorepos = find(fnames =='_'); stocks = unique(cellstr(fnames(:,1:uscorepos-1))); ??? Index exceeds matrix dimensions. If you could suggest what i am doing wrong would be much appreciated. Thanks for your help so far. Alex
From: Rune Allnor on 25 Jul 2010 13:51 On 25 Jul, 19:33, "Alex Eptas" <fe0...(a)mail.wbs.ac.uk> wrote: > Hi Rune > Sorry if you think i am wining, i am a very basic user, obviously things like this are very easy to you. When i try the specific example you have it works find. However when i try to use it to get a list of stocks or dates for the entire data set it does not work; > > rootDir = 'C:\Desktop\Dissertation Data\lseTickBins\'; > > tmp = dir([rootDir '*.csv']); % Note with the csv files you need '*.csv' NOT '*.*.csv' > fnames = char({tmp.name}'); > clear tmp; % fine up to here > > uscorepos = find(fnames =='_'); > > stocks = unique(cellstr(fnames(:,1:uscorepos-1))); > ??? Index exceeds matrix dimensions. > > If you could suggest what i am doing wrong would be much appreciated. With the proviso that *all* filenames are on the format indicated, something like this would work (not tested - any further error checks and debugging is left to you): fnames = dir (directory); N = length(fnames); for n=1:N if (~isdir(fnames(n))) uscorepos = find(fname(n).name == '_'); stockID = fname(n).name(1:uscorepos-1); disp(stockID) end end end Rune
From: us on 25 Jul 2010 15:20 "Alex Eptas" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2hsgg$hhv$1(a)fred.mathworks.com>... > Hi Rune > Sorry if you think i am wining, i am a very basic user, obviously things like this are very easy to you. When i try the specific example you have it works find. However when i try to use it to get a list of stocks or dates for the entire data set it does not work; > > rootDir = 'C:\Desktop\Dissertation Data\lseTickBins\'; > > tmp = dir([rootDir '*.csv']); % Note with the csv files you need '*.csv' NOT '*.*.csv' one of the many solutions flst=dir(...); % <- your DIR command... flst={flst.name}.'; up=regexp(flst,'_','once'); % <- in case there is more than one underscore... % or: STRFIND()... up=[up{:}]; us
From: Alex Eptas on 25 Jul 2010 15:59 "us " <us(a)neurol.unizh.ch> wrote in message <i2i2p6$g0o$1(a)fred.mathworks.com>... > "Alex Eptas" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2hsgg$hhv$1(a)fred.mathworks.com>... > > Hi Rune > > Sorry if you think i am wining, i am a very basic user, obviously things like this are very easy to you. When i try the specific example you have it works find. However when i try to use it to get a list of stocks or dates for the entire data set it does not work; > > > > rootDir = 'C:\Desktop\Dissertation Data\lseTickBins\'; > > > > tmp = dir([rootDir '*.csv']); % Note with the csv files you need '*.csv' NOT '*.*.csv' > > one of the many solutions > > flst=dir(...); % <- your DIR command... > flst={flst.name}.'; > up=regexp(flst,'_','once'); % <- in case there is more than one underscore... > % or: STRFIND()... > up=[up{:}]; > > us Many thanks for your code which worked find. When i have created the up vector how do i get the list of dates or stocks.? thanks
From: us on 25 Jul 2010 16:16 "Alex Eptas" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2i528$7uv$1(a)fred.mathworks.com>... > "us " <us(a)neurol.unizh.ch> wrote in message <i2i2p6$g0o$1(a)fred.mathworks.com>... > > "Alex Eptas" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2hsgg$hhv$1(a)fred.mathworks.com>... > > > Hi Rune > > > Sorry if you think i am wining, i am a very basic user, obviously things like this are very easy to you. When i try the specific example you have it works find. However when i try to use it to get a list of stocks or dates for the entire data set it does not work; > > > > > > rootDir = 'C:\Desktop\Dissertation Data\lseTickBins\'; > > > > > > tmp = dir([rootDir '*.csv']); % Note with the csv files you need '*.csv' NOT '*.*.csv' > > > > one of the many solutions > > > > flst=dir(...); % <- your DIR command... > > flst={flst.name}.'; > > up=regexp(flst,'_','once'); % <- in case there is more than one underscore... > > % or: STRFIND()... > > up=[up{:}]; > > > > us > > > Many thanks for your code which worked find. > When i have created the up vector how do i get the list of dates or stocks.? > thanks well... one of the solutions - to simply extract the trailing dates... % the data % - assume this is how your FLST looks like... flst={ 'ab_20080101' 'c_20090202' 'def_20100303' }; % the engine r=regexp(flst,'(?<=_)\d+','match'); r=[r{:}]; % the result disp(r); %{ '20080101' '20090202' '20100303' %} us
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Location of detected image using boundary trace Next: Contour plot on 3D surface |