Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Help to extract data from string for datetick function

Subject: Help to extract data from string for datetick function

From: Muhammad

Date: 6 Jun, 2011 07:00:20

Message: 1 of 5

Dear all

I need to extract data from string to use it in datetick function, i have data in the following form

'2009-02-05 07:15:48.545'

I have to make the data compatible with the following format of datetick

''yyyy-mm-dd HH:MM:SS'

so in order to make data compatible with datetick I need to remove '.545' from the data, please help me in this regard.

Irshan

Subject: Help to extract data from string for datetick function

From: Rune Allnor

Date: 6 Jun, 2011 07:16:25

Message: 2 of 5

On Jun 6, 9:00 am, "Muhammad " <irsh...@hotmail.com> wrote:
> Dear all
>
> I need to extract data from string to use it in datetick function, i have data in the following form
>
> '2009-02-05 07:15:48.545'
>
> I have to make the data compatible with the following format of datetick
>
> ''yyyy-mm-dd HH:MM:SS'
>
> so in order to make data compatible with datetick I need to remove  '.545' from the data, please help me in this regard.
>
> Irshan

doc datenum
doc datestr

Rune

Subject: Help to extract data from string for datetick function

From: Muhammad

Date: 6 Jun, 2011 07:32:02

Message: 3 of 5

"Muhammad " <irshan_@hotmail.com> wrote in message <ishtu4$2vu$1@newscl01ah.mathworks.com>...
> Dear all
>
> I need to extract data from string to use it in datetick function, i have data in the following form
>
> '2009-02-05 07:15:48.545'
>
> I have to make the data compatible with the following format of datetick
>
> ''yyyy-mm-dd HH:MM:SS'
>
> so in order to make data compatible with datetick I need to remove '.545' from the data, please help me in this regard.
>
> Irshan

I found the solution I have these values in variable T so this code worked fine for doing what i was asking

position = strfind(T, '.') %to find position of the dot which was 20
string = T;
 %to make new string T1 which contains letter from 1:19 and remove parts after 19
T1 = {string{1}(1:19)}

irshan

Subject: Help to extract data from string for datetick function

From: Muhammad

Date: 6 Jun, 2011 07:46:04

Message: 4 of 5

"Muhammad " <irshan_@hotmail.com> wrote in message <ishvpi$7bf$1@newscl01ah.mathworks.com>...
> "Muhammad " <irshan_@hotmail.com> wrote in message <ishtu4$2vu$1@newscl01ah.mathworks.com>...
> > Dear all
> >
> > I need to extract data from string to use it in datetick function, i have data in the following form
> >
> > '2009-02-05 07:15:48.545'
> >
> > I have to make the data compatible with the following format of datetick
> >
> > ''yyyy-mm-dd HH:MM:SS'
> >
> > so in order to make data compatible with datetick I need to remove '.545' from the data, please help me in this regard.
> >
> > Irshan
>
> I found the solution I have these values in variable T so this code worked fine for doing what i was asking
>
> position = strfind(T, '.') %to find position of the dot which was 20
> string = T;
> %to make new string T1 which contains letter from 1:19 and remove parts after 19
> T1 = {string{1}(1:19)}
>
> irshan


This code is only working for one entry of the data series which is string{1}, How can i apply this code for the complete time series.

irshan

Subject: Help to extract data from string for datetick function

From: Sadik

Date: 6 Jun, 2011 11:06:05

Message: 5 of 5

Hello Irshan,

You can do it in a for loop. Let's say your dates are in a cell array called D. Then,

for k = 1:length(D)
    D{k} = D{k}(1:19);
end

Best.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us