signals - Discretizing functions in Matlab -


i have following function , set of values:

z(t):   {r → [-2,3] | z(t) = sin(0.5×π×t) + cos(2×π×t) + 1  t = [-1 : 0.001 : 1] 

i need determine z(n×ts) = z(n), using sample period ts=0.01, therefore discretizing fucnction.

i tried using d2d, i've understood can applied zpk functions.

is there other way it?

if want 0 order hold approximation of signal, can done following code:

ts = 0.01; t = -1:0.001:1; n = t./ts;  nsampled = nan(size(t)); nsampled(1:10:end) = n(1:10:end);  zcont = @(t)(sin(pi*t/2)+cos(2*pi*t)+1); zzoh  = @(n,ts)(zcont(floor(n).*ts)); zdisc = @(n,ts)(zcont(n.*ts));  figure; plot(t,zcont(t),'b','displayname','continuous'); hold on; plot(t,zzoh(n,ts),'r','displayname','zoh');  stem(t,zdisc(nsampled,ts),'k','displayname','discrete');  legend('show'); 

this give output in attached figure.enter image description here

you can try play ceil() or round() instead of floor() different behavior. if need samples @ integer values of n, different altogether , quite different achieve general case (due roundoff error in floats). however: case work subsampling index done in nsampled subsampling factor 10. non-integer subsampling factor, not work properly.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -