histgram of two data with unequal size

histgram of two data with unequal size

Post by autu » Thu, 05 Dec 2002 04:22:24



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

Post by Jeffrey Walto » Thu, 05 Dec 2002 21:22:45



| 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

Post by Ken Davi » Fri, 06 Dec 2002 01:23:53


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

Post by autu » Fri, 06 Dec 2002 06:45:06


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

Post by Ken Davi » Fri, 06 Dec 2002 07:02:59


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

Post by Steven Lor » Fri, 06 Dec 2002 23:04:49



> 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