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:
Matlab matrix

Subject: Matlab matrix

From: M

Date: 1 Feb, 2013 21:25:08

Message: 1 of 3

How I can put time value like 10:23:34 in a matrix cell. Like below:
a(1,2)= 10:23:34

Regards

Subject: Matlab matrix

From: James Tursa

Date: 1 Feb, 2013 21:46:08

Message: 2 of 3

"M" wrote in message <kehbrk$3pp$1@newscl01ah.mathworks.com>...
> How I can put time value like 10:23:34 in a matrix cell. Like below:
> a(1,2)= 10:23:34

One approach is to use a cell array and have the entry be a string. E.g.,

a = cell(1,2);
a{1,2} = '10:23:34';

James Tursa

Subject: Matlab matrix

From: dpb

Date: 1 Feb, 2013 22:53:31

Message: 3 of 3

On 2/1/2013 3:46 PM, James Tursa wrote:
> "M" wrote in message <kehbrk$3pp$1@newscl01ah.mathworks.com>...
>> How I can put time value like 10:23:34 in a matrix cell. Like below:
>> a(1,2)= 10:23:34
>
> One approach is to use a cell array and have the entry be a string. E.g.,
>
> a = cell(1,2);
> a{1,2} = '10:23:34';
>

And another is to use the fractional portion of a datenum representation--

 >> a{1,2}=datenum('10:23:34',upper('hh:mm:ss'))-
fix(datenum('10:23:34',upper('hh:mm:ss')))
a =
     [] [0.4330]
 >> datestr(a{1,2},'HH:MM:SS')
ans =
10:23:34
 >>

--

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