No BSD License  

Highlights from
Generic Signal Class

from Generic Signal Class by Stefan Bleeck
A generic class that allows easy signal (data in time) managment

sig=changesr(a,sr_neu)
% method of class @signal
% function sig=changesr(sig,sr_neu)
% changes the sample rate of the signal to the new samplerate. 
% the number of points of the signal change!
% new values are interpolated
%
%   INPUT VALUES:
%       sig1:       first @signal
%       sr_new: new samplerate
%
%   RETURN VALUE:
%       sigresult:  @signal `
%
% (c) 2003, University of Cambridge, Medical Research Council 
% Stefan Bleeck (stefan@bleeck.de)
% http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
% $Date: 2003/01/20 18:33:51 $
% $Revision: 1.4 $

function sig=changesr(a,sr_neu)

sr_alt=a.samplerate;
if fround(sr_alt,5)==fround(sr_neu,5)   %nichts zu tun
    sig=a;
    return;
end


if sr_neu > sr_alt
    r=round(sr_neu/sr_alt);
%     r=sr_neu/sr_alt;
%     y = interp(a.werte,r);
    x_val_new = a.start_time+1/sr_neu:1/sr_neu:getlength(a);
    x_val_old = a.start_time+1/sr_alt:1/sr_alt:getlength(a);
    y = interp1(x_val_old, a.werte, x_val_new, 'cubic');
else
    p=sr_neu;
    q=sr_alt;
    y = resample(a.werte,p,q);
end

sig=signal(y);
sig.samplerate=sr_neu;
sig.name=a.name;
sig.unit_x=a.unit_x;
sig.unit_y=a.unit_y;
sig.start_time=a.start_time;
sig.nr_x_ticks=a.nr_x_ticks;
sig.x_tick_labels=a.x_tick_labels;

Contact us at files@mathworks.com