Question:
How do I plot a histogram and Box plot using Matlab?
Kala J
2010-02-14 10:52:42 UTC
I have a set of data, Only x values but I want to find the mean, median, standard deviation as well as plot a histogram and box plot using Matlab but I'm not sure how? Actually, I know how to get it into a histogram but I can't label the axises and analyze the data.

What sort of commands and codes should I use? My data is saved under workplace but I'm not sure how to get connect an M-File with the data to input commands, connect the plot and label the graph.

Thanks.
Four answers:
anonymous
2010-02-17 23:42:38 UTC
I'm not sure what you're trying to plot exactly, but try this code, for example:



x = [2 3 4 3 2];

hist(x)



figure

bar(x)



See another example below.

Good luck!

.
?
2016-12-12 11:03:07 UTC
Boxplot Matlab
?
2016-10-03 13:16:52 UTC
Matlab Boxplot
?
2010-02-19 19:21:18 UTC
to get mean, try this command:

mean(X)

variance: var(X)

standard deviation: std(X)



Plotting Histogram & label:

hist(X);title('histogram');xlabel('bin');ylabel('occurrence');



To create an M-file, all need to do is open an M-file, then paste whatever command that you typed in workspace to M-file, save it and click on the run button. You will get whatever data printed in workspace and histogram plotted.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...