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:
number counting

Subject: number counting

From: Mike Liu

Date: 7 Oct, 2010 12:53:04

Message: 1 of 5

Hi

I have a lot of numbers (from datenum):
19:09:2008 02:19:58 733670
19:09:2008 03:04:59 733670
26:09:2008 03:02:29 733677
08:10:2008 02:28:33 733689
08:10:2008 02:43:35 733689
08:10:2008 02:58:33 733689
08:10:2008 03:13:34 733689
18:10:2008 02:26:09 733699
19:10:2008 02:25:59 733700
25:10:2008 02:25:07 733706

I'd like to count the number for given serial date number(the third columns).
For example, numbers are 4 for 733689.
I try to use histc, but it's wrong.
thank in advance.
Mike

Subject: number counting

From: Sean

Date: 7 Oct, 2010 13:12:04

Message: 2 of 5

"Mike Liu" <sulfateion@gmail.com> wrote in message <i8kfrf$o4$1@fred.mathworks.com>...
> Hi
>
> I have a lot of numbers (from datenum):
> 19:09:2008 02:19:58 733670
> 19:09:2008 03:04:59 733670
> 26:09:2008 03:02:29 733677
> 08:10:2008 02:28:33 733689
> 08:10:2008 02:43:35 733689
> 08:10:2008 02:58:33 733689
> 08:10:2008 03:13:34 733689
> 18:10:2008 02:26:09 733699
> 19:10:2008 02:25:59 733700
> 25:10:2008 02:25:07 733706
>
> I'd like to count the number for given serial date number(the third columns).
> For example, numbers are 4 for 733689.
> I try to use histc, but it's wrong.
> thank in advance.
> Mike

One way:
D =[733670
733670
733677
733689
733689
733689
733689
733699
733700
733706];

U = unique(D);
n = histc(D,U);

table = [U,n]

Subject: number counting

From: Nasser M. Abbasi

Date: 7 Oct, 2010 13:15:55

Message: 3 of 5

On 10/7/2010 5:53 AM, Mike Liu wrote:
> Hi
>
> I have a lot of numbers (from datenum):
> 19:09:2008 02:19:58 733670
> 19:09:2008 03:04:59 733670
> 26:09:2008 03:02:29 733677
> 08:10:2008 02:28:33 733689
> 08:10:2008 02:43:35 733689
> 08:10:2008 02:58:33 733689
> 08:10:2008 03:13:34 733689
> 18:10:2008 02:26:09 733699
> 19:10:2008 02:25:59 733700
> 25:10:2008 02:25:07 733706
>
> I'd like to count the number for given serial date number(the third columns).
> For example, numbers are 4 for 733689.
> I try to use histc, but it's wrong.
> thank in advance.
> Mike


May be

%-- data
A=[733670
733670
733677
733689
733689
733689
733689
733699
733700
733706];

sum(ismember(A,733689))

4

--Nasser

Subject: number counting

From: dpb

Date: 7 Oct, 2010 13:12:38

Message: 4 of 5

Mike Liu wrote:
> Hi
>
> I have a lot of numbers (from datenum):
> 19:09:2008 02:19:58 733670
> 19:09:2008 03:04:59 733670
> 26:09:2008 03:02:29 733677
> 08:10:2008 02:28:33 733689
> 08:10:2008 02:43:35 733689
> 08:10:2008 02:58:33 733689
> 08:10:2008 03:13:34 733689
> 18:10:2008 02:26:09 733699
> 19:10:2008 02:25:59 733700
> 25:10:2008 02:25:07 733706
>
> I'd like to count the number for given serial date number(the third
> columns).
> For example, numbers are 4 for 733689.
...

Well, depends... :)

For _a_ given serial date number, there's only a single value from the
data given as the date number would be date and time from datenum.

If it's for a given day, then that would be the integer portion of the
datenum equal to the specific day datenum.

--

Subject: number counting

From: Mike Liu

Date: 8 Oct, 2010 01:07:04

Message: 5 of 5

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i8kgv3$eiv$1@fred.mathworks.com>...
> "Mike Liu" <sulfateion@gmail.com> wrote in message <i8kfrf$o4$1@fred.mathworks.com>...
> > Hi
> >
> > I have a lot of numbers (from datenum):
> > 19:09:2008 02:19:58 733670
> > 19:09:2008 03:04:59 733670
> > 26:09:2008 03:02:29 733677
> > 08:10:2008 02:28:33 733689
> > 08:10:2008 02:43:35 733689
> > 08:10:2008 02:58:33 733689
> > 08:10:2008 03:13:34 733689
> > 18:10:2008 02:26:09 733699
> > 19:10:2008 02:25:59 733700
> > 25:10:2008 02:25:07 733706
> >
> > I'd like to count the number for given serial date number(the third columns).
> > For example, numbers are 4 for 733689.
> > I try to use histc, but it's wrong.
> > thank in advance.
> > Mike
>
> One way:
> D =[733670
> 733670
> 733677
> 733689
> 733689
> 733689
> 733689
> 733699
> 733700
> 733706];
>
> U = unique(D);
> n = histc(D,U);
>
> table = [U,n]

It works. Thanks a lot.

Mike

Tags for 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