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

1. 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.

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!):

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.

J

2. Originally Posted by redherring
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.

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!):

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.

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

CB

3. 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

4. Originally Posted by yeKciM
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

5. 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

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

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

6. Originally Posted by yeKciM
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

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

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

7. Originally Posted by CaptainBlack
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