## histgram of two data with unequal size

### histgram of two data with unequal size

Hi, I wish to draw a histogram of two data, one with length of 60 and
the other with length of 1000, and in the way that readers can see the
difference in black and white. How can I do this ? thank you.

### histgram of two data with unequal size

| Hi, I wish to draw a histogram of two data, one with length of 60 and
| the other with length of 1000, and in the way that readers can see the
| difference in black and white. How can I do this ? thank you.

Hi autumn,

See if the following helps:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hist.shtml#...

Jeff

### histgram of two data with unequal size

Hello,

I assume that you want to show the sample probability density functions, use
the following:

% Make data sets of different lengths.
x=randn(100,1);
y=randn(1000,1)+1;

% Let Matlab find the bin positions that include both data sets.
[dummy, t] = hist([x;y], 20);

nx = hist(x, t); % Sort x into bins.
nx = transpose(nx/sum(nx));
ny = hist(y, t); % Sort y into bins.
ny = transpose(ny/sum(ny));

% Plot bin counts as bars.
bar(t, [nx, ny])

If you just want to show the actual (unnormalized) distributions, use the
same code, but don't divide by sum(nx) and sum(ny).

HTH,

Ken

Quote:> Hi, I wish to draw a histogram of two data, one with length of 60 and
> the other with length of 1000, and in the way that readers can see the
> difference in black and white. How can I do this ? thank you.

### histgram of two data with unequal size

Yes, but I cannot set a vector Y where the size of Y(:,1) and Y(:,2)
are different ?

> | Hi, I wish to draw a histogram of two data, one with length of 60 and
> | the other with length of 1000, and in the way that readers can see the
> | difference in black and white. How can I do this ? thank you.

> Hi autumn,

> See if the following helps:
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hist.shtml#...

> Jeff

### histgram of two data with unequal size

Hello,

I do not understand this message. Who are you replying to? What are Y(:,1)
and Y(:,2)?

Ken

> Yes, but I cannot set a vector Y where the size of Y(:,1) and Y(:,2)
> are different ?

> > | Hi, I wish to draw a histogram of two data, one with length of 60 and
> > | the other with length of 1000, and in the way that readers can see the
> > | difference in black and white. How can I do this ? thank you.

> > Hi autumn,

> > See if the following helps:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/hist.shtml#...
Quote:

> > Jeff

### histgram of two data with unequal size

> Yes, but I cannot set a vector Y where the size of Y(:,1) and Y(:,2)
> are different ?

No.  All rows of a matrix must be the same length and all columns must be
the same length (the row lengths can be different from the column lengths,
of course.)  So for example, this is not a legal set of commands in MATLAB:

A=1:5;
B=1:3;
LA=length(A)
LB=length(B)
[A; B]

You'll receive the error on the last line:

??? Error using ==> vertcat
All rows in the bracketed expression must have the same
number of columns.

_Cell_ arrays will allow you to do this, but many operations (the basic
linear algebra operations, for example) aren't defined for cell arrays.  You
may want to pad your arrays to fit them into the same matrix, like:

[A;B zeros(1,LA-LB)]

--
Steve Lord

We have developed a code to define degree of similarity between
unequal-sized time sequences. Can anybody suggest possible applications for
this ?

For example, comparing musical scores with unequal rate

Thanks for the feedback.