From: TideMan on
On May 12, 12:14 pm, "Ayotunde " <rhyme...(a)yahoo.co.uk> wrote:
> > The symptoms suggest that your format is not quite right.
> > Check that you have the right number of %s and %f for each value in
> > the line.  I suspect you're missing one of the %f's.
> > Post your textscan and we can check that.
>
> > I don't think reading books will improve your Matlab.
> > Doing it is better than reading about it.
> > And this forum is excellent.  Read threads that are not apparently
> > relevant and you often find stuff that is useful in your application.
> > When I first started, I read anything posted by us (and I still do).
> > And providing you're prepared to have a go (as you've demonstrated
> > already), there are plenty of people here who will help you with your
> > coding problems.
> > But what really pisses people off is posters who make no effort and
> > say stuff like "I need the code for x, y, and z.  It is really
> > urgent.  Plz, plz, plz"
>
> I edited the format as you said and i was missing 1 of the %f's. Is %s used for strings maybe dates and time and %f for just numbers? Guessed where to out the missing %f and i'm getting something that looks sensible but insead of getting a 1x9 cell array with nine 360579x1 matrices, i am getting nine 27x1 matrices instead. I am sure its a small problem with my code so i copied it>> fid=fopen('244019298.csv');
> >> C=textscan(fid,'%s%f%s%f%f%f%f%f%s',...
>
> 'headerlines',1,...
> 'delimiter',',');>> fclose(fid);
>
> Yer i understand what you mean, I am certainly no saint myself but i can see where you are coming from, people like you are here to help not do the whole thing for us :)
> thnx again

No, there's something wrong with your data.
There appear to be different numbers of values on each line.
It's hard to tell from what you posted because some of the numbers
have merged.
Can you open the file in notepad or wordpad, copy a few lines (with
the commas) and post that?
From: Ayotunde on
TideMan <mulgor(a)gmail.com> wrote in message <07b9426d-cc62-40f9-90a8-3a72f2e3556d(a)q36g2000prg.googlegroups.com>...
> On May 12, 12:14 pm, "Ayotunde " <rhyme...(a)yahoo.co.uk> wrote:
> > > The symptoms suggest that your format is not quite right.
> > > Check that you have the right number of %s and %f for each value in
> > > the line.  I suspect you're missing one of the %f's.
> > > Post your textscan and we can check that.
> >
> > > I don't think reading books will improve your Matlab.
> > > Doing it is better than reading about it.
> > > And this forum is excellent.  Read threads that are not apparently
> > > relevant and you often find stuff that is useful in your application.
> > > When I first started, I read anything posted by us (and I still do).
> > > And providing you're prepared to have a go (as you've demonstrated
> > > already), there are plenty of people here who will help you with your
> > > coding problems.
> > > But what really pisses people off is posters who make no effort and
> > > say stuff like "I need the code for x, y, and z.  It is really
> > > urgent.  Plz, plz, plz"
> >
> > I edited the format as you said and i was missing 1 of the %f's. Is %s used for strings maybe dates and time and %f for just numbers? Guessed where to out the missing %f and i'm getting something that looks sensible but insead of getting a 1x9 cell array with nine 360579x1 matrices, i am getting nine 27x1 matrices instead. I am sure its a small problem with my code so i copied it>> fid=fopen('244019298.csv');
> > >> C=textscan(fid,'%s%f%s%f%f%f%f%f%s',...
> >
> > 'headerlines',1,...
> > 'delimiter',',');>> fclose(fid);
> >
> > Yer i understand what you mean, I am certainly no saint myself but i can see where you are coming from, people like you are here to help not do the whole thing for us :)
> > thnx again
>
> No, there's something wrong with your data.
> There appear to be different numbers of values on each line.
> It's hard to tell from what you posted because some of the numbers
> have merged.
> Can you open the file in notepad or wordpad, copy a few lines (with
> the commas) and post that?

Here you go, copied quite a bit for good measure
SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX
SPY,19980102,09:31:41,97.3125,53500,0,0,,A
SPY,19980102,09:31:43,97.3125,100,0,0,,M
SPY,19980102,09:31:43,97.3125,200,0,0,,M
SPY,19980102,09:31:44,97.3125,4800,0,0,,P
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,500,0,0,,M
SPY,19980102,09:31:44,97.3125,200,0,0,,M
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,500,0,0,,M
SPY,19980102,09:31:44,97.3125,1000,0,0,,M
SPY,19980102,09:31:44,97.3125,200,0,0,,M
SPY,19980102,09:31:44,97.3125,200,0,0,,M
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,100,0,0,,M
SPY,19980102,09:31:44,97.3125,200,0,0,,M
SPY,19980102,09:31:44,97.3125,1000,0,0,,M
SPY,19980102,09:31:45,97.3125,900,0,0,,M
SPY,19980102,09:31:45,97.3125,300,0,0,,M
SPY,19980102,09:31:45,97.3125,200,0,0,,M
SPY,19980102,09:31:45,97.3125,300,0,0,,M
SPY,19980102,09:31:52,97.3125,200,0,0,,T
SPY,19980102,09:32:03,97.4375,1000,0,0,,A
SPY,19980102,09:32:11,97.4375,1000,0,0,,A
SPY,19980102,09:32:20,97.3125,100,0,0,Z,P
SPY,19980102,09:32:21,97.3125,200,0,0,,T
SPY,19980102,09:32:21,97.3125,100,0,0,,T
SPY,19980102,09:32:21,97.3125,200,0,0,,T
SPY,19980102,09:32:21,97.3125,100,0,0,,T
SPY,19980102,09:32:21,97.3125,100,0,0,,T
SPY,19980102,09:32:21,97.3125,300,0,0,,T
SPY,19980102,09:32:21,97.3125,100,0,0,,T
SPY,19980102,09:32:21,97.3125,500,0,0,,T
From: TideMan on
On May 12, 1:21 pm, "Ayotunde " <rhyme...(a)yahoo.co.uk> wrote:
> TideMan <mul...(a)gmail.com> wrote in message <07b9426d-cc62-40f9-90a8-3a72f2e35...(a)q36g2000prg.googlegroups.com>...
> > On May 12, 12:14 pm, "Ayotunde " <rhyme...(a)yahoo.co.uk> wrote:
> > > > The symptoms suggest that your format is not quite right.
> > > > Check that you have the right number of %s and %f for each value in
> > > > the line.  I suspect you're missing one of the %f's.
> > > > Post your textscan and we can check that.
>
> > > > I don't think reading books will improve your Matlab.
> > > > Doing it is better than reading about it.
> > > > And this forum is excellent.  Read threads that are not apparently
> > > > relevant and you often find stuff that is useful in your application.
> > > > When I first started, I read anything posted by us (and I still do)..
> > > > And providing you're prepared to have a go (as you've demonstrated
> > > > already), there are plenty of people here who will help you with your
> > > > coding problems.
> > > > But what really pisses people off is posters who make no effort and
> > > > say stuff like "I need the code for x, y, and z.  It is really
> > > > urgent.  Plz, plz, plz"
>
> > > I edited the format as you said and i was missing 1 of the %f's. Is %s used for strings maybe dates and time and %f for just numbers? Guessed where to out the missing %f and i'm getting something that looks sensible but insead of getting a 1x9 cell array with nine 360579x1 matrices, i am getting nine 27x1 matrices instead. I am sure its a small problem with my code so i copied it>> fid=fopen('244019298.csv');
> > > >> C=textscan(fid,'%s%f%s%f%f%f%f%f%s',...
>
> > > 'headerlines',1,...
> > > 'delimiter',',');>> fclose(fid);
>
> > > Yer i understand what you mean, I am certainly no saint myself but i can see where you are coming from, people like you are here to help not do the whole thing for us :)
> > > thnx again
>
> > No, there's something wrong with your data.
> > There appear to be different numbers of values on each line.
> > It's hard to tell from what you posted because some of the numbers
> > have merged.
> > Can you open the file in notepad or wordpad, copy a few lines (with
> > the commas) and post that?
>
> Here you go, copied quite a bit for good measure
> SYMBOL,DATE,TIME,PRICE,SIZE,G127,CORR,COND,EX
> SPY,19980102,09:31:41,97.3125,53500,0,0,,A
> SPY,19980102,09:31:43,97.3125,100,0,0,,M
> SPY,19980102,09:31:43,97.3125,200,0,0,,M
> SPY,19980102,09:31:44,97.3125,4800,0,0,,P
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,500,0,0,,M
> SPY,19980102,09:31:44,97.3125,200,0,0,,M
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,500,0,0,,M
> SPY,19980102,09:31:44,97.3125,1000,0,0,,M
> SPY,19980102,09:31:44,97.3125,200,0,0,,M
> SPY,19980102,09:31:44,97.3125,200,0,0,,M
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,100,0,0,,M
> SPY,19980102,09:31:44,97.3125,200,0,0,,M
> SPY,19980102,09:31:44,97.3125,1000,0,0,,M
> SPY,19980102,09:31:45,97.3125,900,0,0,,M
> SPY,19980102,09:31:45,97.3125,300,0,0,,M
> SPY,19980102,09:31:45,97.3125,200,0,0,,M
> SPY,19980102,09:31:45,97.3125,300,0,0,,M
> SPY,19980102,09:31:52,97.3125,200,0,0,,T
> SPY,19980102,09:32:03,97.4375,1000,0,0,,A
> SPY,19980102,09:32:11,97.4375,1000,0,0,,A
> SPY,19980102,09:32:20,97.3125,100,0,0,Z,P
> SPY,19980102,09:32:21,97.3125,200,0,0,,T
> SPY,19980102,09:32:21,97.3125,100,0,0,,T
> SPY,19980102,09:32:21,97.3125,200,0,0,,T
> SPY,19980102,09:32:21,97.3125,100,0,0,,T
> SPY,19980102,09:32:21,97.3125,100,0,0,,T
> SPY,19980102,09:32:21,97.3125,300,0,0,,T
> SPY,19980102,09:32:21,97.3125,100,0,0,,T
> SPY,19980102,09:32:21,97.3125,500,0,0,,T

Ahaaaa................
The second last column is text, not numbers.
This means the format string must be:
'%s%s%s%f%f%f%f%s%s'
Note that I'm also reading in the date (2nd column) as a string.
This means you convert to Matlab days like this:
t=datenum([char(c{2}) char(c{3})],'yyyymmddHH:MM:SS');
You can check if it is right by printing the start and finish times
like this:
datestr([t(1);t(end)])
From: Ayotunde on
> Ahaaaa................
> The second last column is text, not numbers.
> This means the format string must be:
> '%s%s%s%f%f%f%f%s%s'
> Note that I'm also reading in the date (2nd column) as a string.
> This means you convert to Matlab days like this:
> t=datenum([char(c{2}) char(c{3})],'yyyymmddHH:MM:SS');
> You can check if it is right by printing the start and finish times
> like this:
> datestr([t(1);t(end)])

I hate being a bother but this is what i get when i try to convert to matlab days
>> t=datenum([char(C{2})char(C{3})],'yyyymmddHH:MM:SS');
??? t=datenum([char(C{2})char(C{3})],'yyyymmddHH:MM:SS');
|
Error: Unexpected MATLAB expression.
I have tried different things but i just suck :(
thnx
From: TideMan on
On May 12, 3:50 pm, "Ayotunde " <rhyme...(a)yahoo.co.uk> wrote:
>  > Ahaaaa................
>
> > The second last column is text, not numbers.
> > This means the format string must be:
> > '%s%s%s%f%f%f%f%s%s'
> > Note that I'm also reading in the date (2nd column) as a string.
> > This means you convert to Matlab days like this:
> > t=datenum([char(c{2}) char(c{3})],'yyyymmddHH:MM:SS');
> > You can check if it is right by printing the start and finish times
> > like this:
> > datestr([t(1);t(end)])
>
> I hate being a bother but this is what i get when i try to convert to matlab days>> t=datenum([char(C{2})char(C{3})],'yyyymmddHH:MM:SS');
>
> ??? t=datenum([char(C{2})char(C{3})],'yyyymmddHH:MM:SS');
>                          |
> Error: Unexpected MATLAB expression.
> I have tried different things but i just suck :(
> thnx

I'm afraid you are going to get nowhere with Matlab if you cannot do
some simple debugging on a problem like this yourself.
So I'm not going to spoon-feed you anymore.
You'll just have to work it out.

Hint: How is the expression different from what I gave you?