annotate aim-mat/tools/@signal/signal.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % constructor of class @signal
tomwalters@0 2 % parent class: none
tomwalters@0 3 % function sig=signal(length,samplerate,name,unit_x,unit_y,start_time)
tomwalters@0 4 % INPUT VALUES:
tomwalters@0 5 % length: length of signal in seconds [default 1]
tomwalters@0 6 % samplerate: samplerate in Hz (points per seconds) [default: 1000]
tomwalters@0 7 % name: display name of the signal (string)
tomwalters@0 8 % unit_x: display unit on x-axis (string)
tomwalters@0 9 % unit_y: display unit on y-axis (string)
tomwalters@0 10 % start_time: virtual start time of the signal (default 0)
tomwalters@0 11 %
tomwalters@0 12 % RETURN VALUE:
tomwalters@0 13 % @signal-object
tomwalters@0 14 %
tomwalters@0 15 % Valid constructor-calls:
tomwalters@0 16 % 1: no or any number of arguments above
tomwalters@0 17 % 2: signal(@other_signal_object) : Copy-Constructor
tomwalters@0 18 % 3: signal(values): copies the values in the @signal
tomwalters@0 19 %
tomwalters@0 20 % a signal consist of n points according to its length*sr
tomwalters@0 21 % the time "0" is not associated with a bin. the first bin is time sr, the
tomwalters@0 22 % second 2*sr, etc the nth bin is the signal-duration
tomwalters@0 23 %
bleeck@3 24 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 25 % (c) 2011, University of Southampton
bleeck@3 26 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 27 % download of current version is on the soundsoftware site:
bleeck@3 28 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 29 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 30
tomwalters@0 31 function sig=signal(laenge,samplerate,name,unit_x,unit_y,start_time)
tomwalters@0 32
tomwalters@0 33
tomwalters@0 34 if nargin < 6
tomwalters@0 35 start_time=0;
tomwalters@0 36 end
tomwalters@0 37 if nargin < 5
tomwalters@0 38 unit_y='amplitude';
tomwalters@0 39 end
tomwalters@0 40 if nargin < 4
tomwalters@0 41 unit_x='time (ms)';
tomwalters@0 42 end
tomwalters@0 43 if nargin < 3
tomwalters@0 44 name='generic Signal';
tomwalters@0 45 end
tomwalters@0 46 if nargin < 2
tomwalters@0 47 samplerate=1000;
tomwalters@0 48 end
tomwalters@0 49 if nargin < 1
tomwalters@0 50 laenge=1;
tomwalters@0 51 end
tomwalters@0 52
tomwalters@0 53 if isobject(laenge)
tomwalters@0 54 sig.werte=laenge.werte;
tomwalters@0 55 samplerate=laenge.samplerate;
tomwalters@0 56 name=laenge.name;
tomwalters@0 57 unit_x=laenge.unit_x;
tomwalters@0 58 unit_y=laenge.unit_y;
tomwalters@0 59 start_time=laenge.start_time;
tomwalters@0 60 % sig.nr_x_ticks=laenge.nr_x_ticks;
tomwalters@0 61 % sig.x_tick_labels=laenge.x_tick_labels;
tomwalters@0 62 else
tomwalters@0 63 a1=size(laenge,1); a2=size(laenge,2);
tomwalters@0 64 if a1>1 & a2>1
tomwalters@0 65 disp('Signal Constructor Error: input vector has more than one dimension');
tomwalters@0 66 end
tomwalters@0 67 % erst Abfrage, welche Konstruktionsmethode:
tomwalters@0 68 if a2>1 %Benutzer hat Zeilenvektor eingegeben, wir wollen einen Spaltenvektor
tomwalters@0 69 laenge=laenge';
tomwalters@0 70 a1=a2;
tomwalters@0 71 end
tomwalters@0 72 if a1>1 % AHA! Ein Vektor
tomwalters@0 73 sig.werte=laenge;
tomwalters@0 74 else
tomwalters@0 75 nr_points=round(laenge*samplerate);
tomwalters@0 76 sig.werte=zeros(nr_points,1);
tomwalters@0 77 end
tomwalters@0 78 end
tomwalters@0 79 sig.samplerate=samplerate;
tomwalters@0 80 sig.name=name;
tomwalters@0 81 sig.unit_x=unit_x;
tomwalters@0 82 sig.unit_y=unit_y;
tomwalters@0 83 sig.start_time=start_time;
tomwalters@0 84 sig.nr_x_ticks=9;
tomwalters@0 85 % if the ticks shell be numbers or something else
tomwalters@0 86 sig.x_tick_labels=[];
tomwalters@0 87
tomwalters@0 88 sig=class(sig,'signal');