|
"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ij6akf$67d$1@fred.mathworks.com>...
> Hi,
>
> > Delete rows with time values from 10150000 to 10295959 for all rows (or extract these values) ?
>
> In order to show you the functionality of the code with deleting rows outside the required range, I have prepared a modfified data "data2.txt":
>
> Stock Date Time Price Volume Stock Category
> ETE 04/01/2010 10145959 18.34 500 Big Cap
> ETE 04/01/2010 10150000 18.34 70 Big Cap
> ETE 04/01/2010 10170000 18.34 430 Big Cap
> ABC 04/01/2010 10190000 18.34 200 Big Cap
> YYY 04/01/2010 10200000 18.34 100 Big Cap
> ETE 04/01/2010 10250000 18.34 40 Big Cap
> ETE 04/01/2010 10295959 18.34 215 Big Cap
> ETE 04/01/2010 10300000 18.34 500 Big Cap
> ETE 04/01/2010 10320000 18.34 500 Big Cap
>
> The following code makes what you required:
>
> % Pap2 2011-02-12
> % Function "inp.m" for manual input from keyboard:
> % www.mathworks.com/matlabcentral/fileexchange/9033
>
> file = inp('file name','data2.txt'); % Enter name of the file to be processed
> fid = fopen(file,'r');
> C = textscan(fid,'%*s%*s%n%n%n%*[^\n]','headerLines',1);
> fclose(fid);
>
> time1 = inp('time1',10150000,'%8d'); % lower boundary of time period
> time2 = inp('time2',10295959); % upper boundary of time period
>
> I = C{:,1}>=time1 & C{:,1}<=time2; % logicals of accepted times
> % D = [time price volume] between time1 and time 2 included:
> D = [C{:}]; % It may be put into C for sparing memory space
> D = D(I,2:3) % Columns 4 & 5 in C are columns 2 & 3 in D
>
> There are the results of a run:
>
> >> Pap2
> file name = data2.txt =>
> time1 = 10150000 =>
> time2 = 10295959 =>
> D =
> 18.3400 70.0000
> 18.3400 430.0000
> 18.3400 200.0000
> 18.3400 100.0000
> 18.3400 40.0000
> 18.3400 215.0000
>
> You see that only rows within the required times are present.
>
> Best regards
>
> Mira
>
> PS:
> Maybe that the stock code be also interesting. In that case you may either modify the format in textscan and process bigger matrix, or read the same file for the second time and extract only the first column. Afterwards, you may apply the same logical vector "I" for selecting the required rows.
Hello,
Can anyone help?
I am trying to run the above function.
1. After running the textscan function hoe can I the results (cell arrays) exported in a new Text/Excel file?
2. When I run the function for selecting loewr and upper bounds to delete rows I get the below error message:
> time1=('time1',10300000,'%8d');
??? time1=('time1',10300000,'%8d');
|
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
Can anyone help please?
Pap
|