Mercurial > hg > octave-nkf
view test/test_signal.m @ 5851:acb4a1e0b311 ss-2-9-6
[project @ 2006-06-09 16:34:42 by jwe]
author | jwe |
---|---|
date | Fri, 09 Jun 2006 16:37:20 +0000 |
parents | 1ad66ea35fe5 |
children | 3f4ccca05612 |
line wrap: on
line source
%% Automatically generated from DejaGNU files %% test/octave.test/signal/detrend-1.m %% detrend-1.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! N=32; %! x = (0:1:N-1)/N + 2; %! y = detrend(x); %! assert(all (all (abs (y) < 10*eps))); %% test/octave.test/signal/detrend-2.m %% detrend-2.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! N=32; %! t = (0:1:N-1)/N; %! x = t .* t + 2; %! y = detrend(x,2); %! assert(all (all (abs (y) < 30*eps))); %% test/octave.test/signal/detrend-3.m %% detrend-3.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! N=32; %! t = (0:1:N-1)/N; %! x = [t;4*t-3]'; %! y = detrend(x); %! assert(all (all (abs (y) < 20*eps))); %% test/octave.test/signal/fft-1.m %% fft-1.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! N=64; %! n=4; %! t = 2*pi*(0:1:N-1)/N; %! s = cos(n*t); %! S = fft(s); %! %! answer = 0*t; %! answer(n+1) = N/2; %! answer(N-n+1) = N/2; %! %! assert(all( abs(S-answer) < 4*N*eps )); %% test/octave.test/signal/ifft-1.m %% ifft-1.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! N=64; %! n=7; %! t = 2*pi*(0:1:N-1)/N; %! s = cos(n*t); %! %! S = 0*t; %! S(n+1) = N/2; %! S(N-n+1) = N/2; %! %! assert(all( abs(ifft(S)-s) < 4*N*eps )); %% test/octave.test/signal/fft2-1.m %% fft2-1.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! M=16; %! N=8; %! %! m=5; %! n=3; %! %! x = 2*pi*(0:1:M-1)/M; %! y = 2*pi*(0:1:N-1)/N; %! sx = cos(m*x); %! sy = sin(n*y); %! s=kron(sx',sy); %! S = fft2(s); %! answer = kron(fft(sx)',fft(sy)); %! assert(all( all( abs(S-answer) < 4*M*N*eps ) )); %% test/octave.test/signal/ifft2-1.m %% ifft2-1.m %% %% Author: David Billinghurst (David.Billinghurst@riotinto.com.au) %% Comalco Research and Technology %% 02 May 2000 %!test %! M=12; %! N=7; %! %! m=3; %! n=2; %! %! x = 2*pi*(0:1:M-1)/M; %! y = 2*pi*(0:1:N-1)/N; %! %! sx = cos(m*x); %! sy = cos(n*y); %! %! S = kron(fft(sx)',fft(sy)); %! answer=kron(sx',sy); %! s = ifft2(S); %! %! assert(all( all( abs(s-answer) < 30*eps ) )); %% test/octave.test/signal/unwrap-1.m %!function t = assert(a,b,tol) %! if (nargin == 1) %! t = all(a(:)); %! else %! if (nargin == 2) %! tol = 0; %! endif %! if (any (size(a) != size(b))) %! t = 0; %! elseif (any (abs(a(:) - b(:)) > tol)) %! t = 0; %! else %! t = 1; %! endif %! endif %! %!test %! %! i = 0; %! t = []; %! %! r = [0:100]; # original vector %! w = r - 2*pi*floor((r+pi)/(2*pi)); # wrapped into [-pi,pi] %! tol = 1e3*eps; # maximum expected deviation %! %! t(++i) = assert(r, unwrap(w), tol); #unwrap single row %! t(++i) = assert(r', unwrap(w'), tol); #unwrap single column %! t(++i) = assert([r',r'], unwrap([w',w']), tol); #unwrap 2 columns %! t(++i) = assert([r;r], unwrap([w;w],[],2), tol); #verify that dim works %! t(++i) = assert(r+10, unwrap(10+w), tol); #verify that r(1)>pi works %! %! t(++i) = assert(w', unwrap(w',[],2)); #unwrap col by rows should not change it %! t(++i) = assert(w, unwrap(w,[],1)); #unwrap row by cols should not change it %! t(++i) = assert([w;w], unwrap([w;w])); #unwrap 2 rows by cols should not change them %! %! ## verify that setting tolerance too low will cause bad results. %! t(++i) = assert(any(abs(r - unwrap(w,0.8)) > 100)); %! %! assert(all(t));