Frequency Magnitude histogram plot

2 views (last 30 days)
amberly hadden
amberly hadden on 20 Jul 2014
Commented: Kelly Kearney on 22 Jul 2014
Hi I have two variabes (Freq and magnitude) I want to plot the histogram so that I get Freq on y axis and magnitude on x-axis.
Please guide
  4 Comments
amberly hadden
amberly hadden on 21 Jul 2014
Edited: Image Analyst on 21 Jul 2014
Data Frequency
2.10-2.199 43
2.2-2.299 41
2.3-2.399 31
2.4-2.499 29
2.5-2.599 13
2.6-2.699 9
2.7-2.799 3
2.8-2.899 2
2.9-2.999 1

Sign in to comment.

Answers (1)

Kelly Kearney
Kelly Kearney on 21 Jul 2014
Is this what you had in mind?
xedge = 2.1:.1:3;
freq = [43 41 31 29 13 9 3 2 1];
bar(xedge, [freq 0], 'histc')
  4 Comments
amberly hadden
amberly hadden on 21 Jul 2014
Here is the orignal data set. I have created the ranges lets say 2.1-2.199 and counted numbers in series above 2.1 adn next 2.2-2.299 and again counted numbers above 2.2 and so on to get frequency
2.745 2.422 2.876 2.477 2.440 2.674 2.600 2.450 2.630 2.439 2.432 2.483 2.652 2.255 2.448 2.441 2.447 2.537 2.440 2.671 2.502 2.421 2.438 2.582 2.943 2.387 2.221 2.243 2.214 2.187 2.242 2.426 2.385 2.260 2.647 2.595 2.219 2.471 2.495 2.256 2.133 2.225 2.215
Kelly Kearney
Kelly Kearney on 22 Jul 2014
x = [2.745 2.422 2.876 2.477 2.440 2.674 2.600 2.450 2.630 2.439 ...
2.432 2.483 2.652 2.255 2.448 2.441 2.447 2.537 2.440 2.671 ...
2.502 2.421 2.438 2.582 2.943 2.387 2.221 2.243 2.214 2.187 ...
2.242 2.426 2.385 2.260 2.647 2.595 2.219 2.471 2.495 2.256 ...
2.133 2.225 2.215];
xedge = 2.1:0.1:3;
n = histc(x, xedge);
bar(xedge, n, 'histc');

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!