From: Luna Moon on
On Jul 20, 2:55 pm, Luna Moon <lunamoonm...(a)gmail.com> wrote:
> On Jul 20, 2:40 pm, "us " <u...(a)neurol.unizh.ch> wrote:
>
>
>
> > Luna Moon <lunamoonm...(a)gmail.com> wrote in message <0d4790bc-26d4-4eb5-821b-3c1d18f58...(a)l14g2000yql.googlegroups.com>...
> > > On Jul 20, 2:08 pm, "us " <u...(a)neurol.unizh.ch> wrote:
> > > > Luna Moon <lunamoonm...(a)gmail.com> wrote in message <ce9dc681-4c91-448c-9d91-849c33207...(a)i31g2000yqm.googlegroups.com>...
> > > > > In Matlab, I have a cell array of strings which represents the dates.
>
> > > > > And also have a numerical array of data points, each row of data
> > > > > corresponding to the date...
>
> > > > > I want to output these into CSV file.
>
> > > > > How do I do that?
>
> > > > > I just couldn't figure out a way to do it.
>
> > > > > I have to write out to Excel and then convert back to CSV...
>
> > > > > quite manual.
>
> > > > > Please help me! Thank you!
>
> > > > a hint:
> > > > - this FEX submission does what you want/need...
>
> > > >http://www.mathworks.com/matlabcentral/fileexchange/23840
>
> > > > us
>
> > > I don't see how to use this for my purpose.
>
> > did you look at the section
> > - output files
> >   creating output files
> > in the published M-file
>
> >http://www.mathworks.com/matlabcentral/fx_files/23840/14/content/cphe...
>
> > us
>
> I have looked at output files. But I don't know how to first output
> dates and then output data points and align the data points with the
> dates...

mycell={datestr(MyDates), MyData};
cprintf(mycell, '-fc', 'mytry.csv', '-dt', ',');

doesn't work...
From: us on
Luna Moon <lunamoonmoon(a)gmail.com> wrote in message <4b04e735-d3c9-4a17-8cba-f65ab1a1a773(a)d8g2000yqf.googlegroups.com>...
> On Jul 20, 2:40 pm, "us " <u...(a)neurol.unizh.ch> wrote:
> > Luna Moon <lunamoonm...(a)gmail.com> wrote in message <0d4790bc-26d4-4eb5-821b-3c1d18f58...(a)l14g2000yql.googlegroups.com>...
> > > On Jul 20, 2:08 pm, "us " <u...(a)neurol.unizh.ch> wrote:
> > > > Luna Moon <lunamoonm...(a)gmail.com> wrote in message <ce9dc681-4c91-448c-9d91-849c33207...(a)i31g2000yqm.googlegroups.com>...
> > > > > In Matlab, I have a cell array of strings which represents the dates.
> >
> > > > > And also have a numerical array of data points, each row of data
> > > > > corresponding to the date...
> >
> > > > > I want to output these into CSV file.
> >
> > > > > How do I do that?
> >
> > > > > I just couldn't figure out a way to do it.
> >
> > > > > I have to write out to Excel and then convert back to CSV...
> >
> > > > > quite manual.
> >
> > > > > Please help me! Thank you!
> >
> > > > a hint:
> > > > - this FEX submission does what you want/need...
> >
> > > >http://www.mathworks.com/matlabcentral/fileexchange/23840
> >
> > > > us
> >
> > > I don't see how to use this for my purpose.
> >
> > did you look at the section
> > - output files
> >   creating output files
> > in the published M-file
> >
> > http://www.mathworks.com/matlabcentral/fx_files/23840/14/content/cphe...
> >
> > us
>
>
> I have looked at output files. But I don't know how to first output
> dates and then output data points and align the data points with the
> dates...

one of the solutions
- dependin on what ...exactly... you mean by ...align the data...

c={
datestr(now-1), 1,2,3, 'alpha'
datestr(now), 4,5,6, 'beta'
datestr(now+1), 7 8 9, 'CSSM'
};
cprintf(c,'-ic',1); % <- and/or some of the many other options incl -fc/-fa

us
From: Richard Willey on
The Statistics Toolbox dataset array has an "export" method that supports
CSV format....

http://www.mathworks.com/access/helpdesk/help/toolbox/stats/dataset.export.html


"Luna Moon" <lunamoonmoon(a)gmail.com> wrote in message
news:ce9dc681-4c91-448c-9d91-849c332078be(a)i31g2000yqm.googlegroups.com...
> In Matlab, I have a cell array of strings which represents the dates.
>
> And also have a numerical array of data points, each row of data
> corresponding to the date...
>
> I want to output these into CSV file.
>
> How do I do that?
>
> I just couldn't figure out a way to do it.
>
> I have to write out to Excel and then convert back to CSV...
>
> quite manual.
>
> Please help me! Thank you!


From: us on
Luna Moon
> mycell={datestr(MyDates), MyData};
> cprintf(mycell, '-fc', 'mytry.csv', '-dt', ',');
>
> doesn't work...

yes... because MYCELL is not collected correctly...

one of the solutions

ds=[
now-1
now
now+1
];
dp=[
1 2 3
4 5 6
7 8 9
];
c=[cellstr(datestr(ds)),num2cell(dp)]
%{
% c =
[1x20 char] [1] [2] [3]
[1x20 char] [4] [5] [6]
[1x20 char] [7] [8] [9]
%}
cprintf(c,'-ic',1); % <- and use -fc or -fa as needed...
%{
19-Jul-2010 21:12:37 1 2 3
20-Jul-2010 21:12:37 4 5 6
21-Jul-2010 21:12:37 7 8 9
%}

us