Re: Histogram Functions
- From: Mees <m_oylulan@xxxxxxxxxxx>
- Date: Wed, 24 Aug 2005 08:42:15 -0400
mees wrote:
>
>
> NZTideMan wrote:
>>
>>
>> I don't understand why your being new to Matlab should make
hist
>> difficult.
>> I haven't looked at the details of hist, but I assume it does
>> something
>> like this:
>> 1. Sort the data into ascending order
>> 2. Count the number of data that fall into each bin (either
> defined
>> by
>> the user or assumed to be equispaced from min to max.)
>>
>> You could code this up yourself.
>> All hist is is a shortcut for you, to save you the time coding
> it.
>> If you don't understand how to use it, you should make your own
>> hist to
>> do exactly what you want to achieve.
>> That's what you as a novice needs to learn, i.e., there's
nothing
>> magic
>> about commands like hist or mean or kurtosis. They're just a
>> shortcut.
>> You could code them yourself.
>>
>>
>
> Hi,
>
> A histogram is a graph that shows how frequently a particular
> 'event'
> occurs. Say you have a town with
> a population of 50,000 and you want to figure out
> the age distribution of the inhabitants. To use the
> hist function you would need two set of data:
>
> 1.
> A vector of length 50,000 containing the age of each
> person.
> age = [age_data_goes_here];
>
> 2.
> A vector of bins defining the age categories e.g. in age intervals
> of
> 15 yrs, beginning at 0yrs and ending at 100yrs:
> bin = [0:15:100];
>
> 3.
> With this data the following command in MATLAB:
> hist(bin, age)
>
> should plot a bar graph with the age categories on the
> x-axis and the number of people in that age category on
> the y-axis.
>
> If you did not specify the bin sizes and just typed the command:
> hist(age)
>
> MATLAB would plot the data with 10 bin intervals divided equally
> between the highest and lowest ages that occurred in the age[]
> vector
> above.
>
> In the MATLAB function online help pages, one of the examples
> defines
> the vector of input data (analogous to the age vector above) as a
> random vector y of 10,000 elements:
> y = randn(10000,1);
>
> The bins are defined by a vector x with intervals of 0.1 in the
> range
> -2.9 to 2.9:
> x = -2.9:0.1:2.9;
>
> Hope this helps!
> M
Sorry, I just noticed a typo in the mail above, the code in point 3,
should read:
hist(age, bin);
.
- References:
- Histogram Functions
- From: Michael Ibrahim
- Re: Histogram Functions
- From: NZTideMan
- Re: Histogram Functions
- From: mees
- Histogram Functions
- Prev by Date: *
- Next by Date: Re: Histogram Functions
- Previous by thread: Re: Histogram Functions
- Next by thread: Re: Histogram Functions
- Index(es):
Relevant Pages
|