Results 1 to 7 of 7

Math Help - Plotting "Continuous" Histograms in Octave/Matlab

  1. #1
    Newbie
    Joined
    Jan 2010
    Posts
    6

    Plotting "Continuous" Histograms in Octave/Matlab

    Hi folks,

    I'm in the midst of analyzing a set of data and it involves plotting the distribution of a large number of ions.

    I currently am using the hist function in Octave to do so, and it produces graphs along the following lines, give or take bin-size.

    Plotting "Continuous" Histograms in Octave/Matlab-oldc.jpg

    However, my supervisor does not like this "style" of graph; and wishes to for it to look like the following distribution (not the same data as above!):

    Plotting "Continuous" Histograms in Octave/Matlab-new.jpg

    I was wondering if there was a simple way to do this in Octave, whether its curve fitting to a series of points or something else. Basically, I am in desperate need of a "continuous distribution" graph.

    Thanks in advance. Yours,

    J
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by redherring View Post
    Hi folks,

    I'm in the midst of analyzing a set of data and it involves plotting the distribution of a large number of ions.

    I currently am using the hist function in Octave to do so, and it produces graphs along the following lines, give or take bin-size.

    Click image for larger version. 

Name:	oldc.jpg 
Views:	94 
Size:	15.5 KB 
ID:	18532

    However, my supervisor does not like this "style" of graph; and wishes to for it to look like the following distribution (not the same data as above!):

    Click image for larger version. 

Name:	new.jpg 
Views:	85 
Size:	21.1 KB 
ID:	18533

    I was wondering if there was a simple way to do this in Octave, whether its curve fitting to a series of points or something else. Basically, I am in desperate need of a "continuous distribution" graph.

    Thanks in advance. Yours,

    J
    Google "Kernel Density Estimation" and/or "Kernel Density Estimation octave"

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member yeKciM's Avatar
    Joined
    Jul 2010
    Posts
    456
    hmmm... i didn't use "matlab" for a long time but i'm sure that u can plot what your supervisor wants very easy... sorry i forgot the syntax for that, actually i'm not hundred percent sure, so i don't wont to mislead you... cool thing in matlab is "help" function, so u can see exactly how u can do that what you need

    try that if you have matlab, it's very easy to manipulate with type of plot you need, to look very nice you don't have to type more than few lines of code
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by yeKciM View Post
    hmmm... i didn't use "matlab" for a long time but i'm sure that u can plot what your supervisor wants very easy... sorry i forgot the syntax for that, actually i'm not hundred percent sure, so i don't wont to mislead you... cool thing in matlab is "help" function, so u can see exactly how u can do that what you need

    try that if you have matlab, it's very easy to manipulate with type of plot you need, to look very nice you don't have to type more than few lines of code
    I beleive that Matlab has kernel density estimation in one of its tool-boxes. KDE is the only method I know for producing smooth estimates of a density from sample data (that and its a pretty cool method).

    As usual the wikipedia KDE article is useful, even pointing to the Matlab function that will do the job.

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Senior Member yeKciM's Avatar
    Joined
    Jul 2010
    Posts
    456
    although i was more in to "simulik" with matlab i think that this is what u need

    here is one m-file (that u need to make or u can write this directly in command window)


    clear all
    close all
    clc

    t=-5:0.01:5 ;
    x=cos(10*pi*t)+sin(2*pi*t);
    figure(1)
    plot(t,x,'r')
    axis([-5 5 -2.5 2.5])
    title('x(t)=cos(10 \pi t )+sin (2 \pi t')
    xlabel('t')
    ylabel('x(t)')
    grid on

    Plotting "Continuous" Histograms in Octave/Matlab-signal1.jpg


    or u can do in multicolor like this

    clear all
    close all
    clc

    t=-5:0.01:5 ;

    x1=exp((0.2+j*pi)*t);
    x2=exp((-0.2+j*pi)*t);
    x3=exp((0+j*pi)*t);

    figure(2)

    plot(t,real(x1))
    hold on
    plot(t,imag(x1),'r')
    hold on
    plot(t,real(x2),'--m')
    hold on
    plot(t,real(x3),'--k')
    axis([-5 5 -2.5 2.5])
    title('x(t)=e^{(\sigma+j\omega) t}')
    xlabel('t')
    ylabel('y(t)')
    grid on

    Plotting "Continuous" Histograms in Octave/Matlab-signal2.jpg

    maybe you should post what is the function that you need to plot, or what values you need , maybe i'll remember something else that should be more acceptable to you and your supervisor
    this you should get if u type that codes above ... easy you can change type and thickness of lines



    Edit:
    P.S. or if you don't know function that describe what you need, we can always (if u know in specific time intervals values of that function) approximate (very good) how doe's it act between two points... and lot's of another things
    Last edited by yeKciM; August 13th 2010 at 09:29 AM.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by yeKciM View Post
    although i was more in to "simulik" with matlab i think that this is what u need

    here is one m-file (that u need to make or u can write this directly in command window)


    clear all
    close all
    clc

    t=-5:0.01:5 ;
    x=cos(10*pi*t)+sin(2*pi*t);
    figure(1)
    plot(t,x,'r')
    axis([-5 5 -2.5 2.5])
    title('x(t)=cos(10 \pi t )+sin (2 \pi t')
    xlabel('t')
    ylabel('x(t)')
    grid on

    Click image for larger version. 

Name:	signal1.JPG 
Views:	96 
Size:	45.6 KB 
ID:	18545


    or u can do in multicolor like this

    clear all
    close all
    clc

    t=-5:0.01:5 ;

    x1=exp((0.2+j*pi)*t);
    x2=exp((-0.2+j*pi)*t);
    x3=exp((0+j*pi)*t);

    figure(2)

    plot(t,real(x1))
    hold on
    plot(t,imag(x1),'r')
    hold on
    plot(t,real(x2),'--m')
    hold on
    plot(t,real(x3),'--k')
    axis([-5 5 -2.5 2.5])
    title('x(t)=e^{(\sigma+j\omega) t}')
    xlabel('t')
    ylabel('y(t)')
    grid on

    Click image for larger version. 

Name:	signal2.JPG 
Views:	134 
Size:	49.8 KB 
ID:	18546

    maybe you should post what is the function that you need to plot, or what values you need , maybe i'll remember something else that should be more acceptable to you and your supervisor
    this you should get if u type that codes above ... easy you can change type and thickness of lines



    Edit:
    P.S. or if you don't know function that describe what you need, we can always (if u know in specific time intervals values of that function) approximate (very good) how doe's it act between two points... and lot's of another things
    If you read the original post you might notice what the OP has is sample data. KDE will allow the expression of the estimated PDF as a function which can then be plotted.

    CB
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Senior Member yeKciM's Avatar
    Joined
    Jul 2010
    Posts
    456
    Quote Originally Posted by CaptainBlack View Post
    If you read the original post you might notice what the OP has is sample data. KDE will allow the expression of the estimated PDF as a function which can then be plotted.

    CB

    ahh yes, thank you

    that should do the trick i was going totally somewhere else with this, i understand that he has sample data and i assumed that discreet signal (sequence signal) and like you do reconstruction from that signal to analog signal .... we can do this (it can be done like that because that samples in some time intervals are like "discreet signal" and using "butterworth" filter let's say 5th order can be approximated very very good )

    something like this (just reconstruction )

    [b a]=butter(5, 0.01);
    ynfn=filter(b,a,xsh);


    but that what you wrote there is more appropriate for that issue that OP have

    I'm sorry for misleading
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: September 16th 2011, 01:08 AM
  2. Replies: 2
    Last Post: April 24th 2011, 07:01 AM
  3. Replies: 1
    Last Post: October 25th 2010, 04:45 AM
  4. Replies: 1
    Last Post: June 4th 2010, 10:26 PM
  5. Matlab Split vectors,if statements, and "for loop"
    Posted in the Math Software Forum
    Replies: 5
    Last Post: February 27th 2010, 02:30 AM

Search Tags


/mathhelpforum @mathhelpforum