]> Creatis software - CreaPhase.git/blob - octave_packages/signal-1.1.3/sampled2continuous.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / signal-1.1.3 / sampled2continuous.m
1 ## Copyright (C) 2009 Muthiah Annamalai <muthiah.annamalai@uta.edu>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ## Usage:
17 ## 
18 ## xt = sampled2continuous( xn , T, t )
19 ## 
20 ## Calculate the x(t) reconstructed
21 ## from samples x[n] sampled at a rate 1/T samples
22 ## per unit time.
23 ## 
24 ## t is all the instants of time when you need x(t) 
25 ## from x[n]; this time is relative to x[0] and not
26 ## an absolute time.
27 ## 
28 ## This function can be used to calculate sampling rate
29 ## effects on aliasing, actual signal reconstruction
30 ## from discrete samples.
31
32 function xt = sampled2continuous( xn , T, t )
33   if ( nargin < 3 )
34     print_usage()
35   endif
36   
37   N = length( xn );
38   xn = reshape( xn, N, 1 );
39   [TT,tt]= meshgrid(T*(0:N-1)',t);
40   S = sinc((tt -TT)./T);
41   xt = S*xn;
42   return
43 end