how can i make a histogram from 2 vectors of data?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have two vectors of data: X which is length ( X is not evenly distributed)and Y which is frequency of particles at each length.
Is there a function that I can use to make a histogram out of this with a certain bin-width. or in a more general way create a histogram at positions X2(new defined vector for bin position)
note: This data of current form of plot(X,Y) is not a histogram because of the uneven distribution of X. As far as I understand the function hist takes only 1 vector and by calculating mean and all that creates a histogram only from that. which is not the thing i'm after.
0 comentarios
Respuestas (2)
Star Strider
el 27 de Ag. de 2014
It seems from your description that you already have a histogram, with Y being the frequency of particles at each length given in X. If that is the situation, use a bar plot:
X = unique(randi(50,1,15)); % Create Data
Y = randi(50,1,size(X,2)); % Create Data
figure(1)
bar(X, Y)
grid
It will do what it seems you want to do.
3 comentarios
Star Strider
el 27 de Ag. de 2014
The bins are already specified in X. At least that’s the way I read it.
Image Analyst
el 28 de Ag. de 2014
I agree with Star. Somehow he has frequency (the counts) in Y (a very poor name), so Y is already the histogram. The only way he could have gotten that is if it's already been determined which bins the data lie in. So he must have had some data that is a list of a bunch of lengths, say it's called lengths. Then (somehow, in an unspecified way we don't know) he determined what the bins are - their edges or centers or however you want to specify it - and that is what he's calling X (another very non-descriptive poor name in my opinion). Poor naming of variables is one of the most common reasons why people like us who try to answer get confused.
Ver también
Categorías
Más información sobre Histograms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!