tomwalters@0: % method of class @signal tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % bleeck@3: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org tomwalters@0: bleeck@3: bleeck@3: function rethandle=plot(sig,border,style,ax) bleeck@3: % usage: handle=plot(sig,border,style) tomwalters@0: % plots the class signal. This plot works a little bit different from usual. bleeck@3: % Parameter can either be: plot(signal,style) or plot(signal,border) or plot(signal,border,style) tomwalters@0: % the border can consist of times and y-value or only the times that should be plotted (in seconeds!) tomwalters@0: tomwalters@0: if nargin<4 tomwalters@0: ax=gca; tomwalters@0: end tomwalters@0: if nargin<3 bleeck@3: style='b-'; tomwalters@0: end tomwalters@0: bleeck@3: if nargin==2 && all(ishandle(border)) tomwalters@0: ax=border; tomwalters@0: end bleeck@3: if nargin==3 && ishandle(style) bleeck@3: ax=style; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: durationbin=size(sig.werte,1); tomwalters@0: % duration=durationbin/sr; tomwalters@0: if nargin<2 tomwalters@0: t1=1; tomwalters@0: t2=durationbin; tomwalters@0: border=[t1 t2 min(sig.werte(t1:t2)) max(sig.werte(t1:t2))]; tomwalters@0: end tomwalters@0: tomwalters@0: if isstruct(border) || isempty(border) tomwalters@0: options=border; tomwalters@0: t1=1; tomwalters@0: t2=durationbin; tomwalters@0: border=[t1 t2 min(sig.werte(t1:t2)) max(sig.werte(t1:t2))]; tomwalters@0: else tomwalters@0: options=[]; tomwalters@0: if ischar(border) bleeck@3: style=border; tomwalters@0: t1=1; tomwalters@0: t2=durationbin; tomwalters@0: border=[t1 t2 min(sig.werte(t1:t2)) max(sig.werte(t1:t2))]; tomwalters@0: else tomwalters@0: if isempty(border) tomwalters@0: t1=1; tomwalters@0: t2=durationbin; tomwalters@0: border=[t1 t2 min(sig.werte(t1:t2)) max(sig.werte(t1:t2))]; tomwalters@0: else tomwalters@0: t1=border(1); tomwalters@0: t2=border(2); tomwalters@0: x1=time2bin(sig,t1); tomwalters@0: x2=time2bin(sig,t2); tomwalters@0: nr=size(border,2); tomwalters@0: if nr==2 % wenn nur die x-Werte angegeben werden tomwalters@0: border=[x1 x2 min(sig.werte(x1+1:x2)) max(sig.werte(x1+1:x2))]; tomwalters@0: else tomwalters@0: border(1)=x1; tomwalters@0: border(2)=x2; tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: if ~isfield(options,'is_log'); tomwalters@0: is_log=0; tomwalters@0: else tomwalters@0: is_log=options.is_log; tomwalters@0: end tomwalters@0: tomwalters@0: if isfield(options,'minimum_time'); tomwalters@0: border(1)=time2bin(sig,options.minimum_time); tomwalters@0: minimum_time=options.minimum_time; tomwalters@0: else tomwalters@0: minimum_time=bin2time(sig,border(1)); tomwalters@0: end tomwalters@0: tomwalters@0: if isfield(options,'maximum_time'); tomwalters@0: border(2)=time2bin(sig,options.maximum_time); tomwalters@0: maximum_time=options.maximum_time; tomwalters@0: else tomwalters@0: maximum_time=bin2time(sig,border(2)); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % if the time scale is reversed (time from left to right) tomwalters@0: if isfield(options,'time_reversed'); tomwalters@0: time_reversed=options.time_reversed; tomwalters@0: else tomwalters@0: time_reversed=0; tomwalters@0: end tomwalters@0: tomwalters@0: start_time=getminimumtime(sig); tomwalters@0: tomwalters@0: min_x_screen=border(1); % einer wird abgezogen damit wir bei Null beginnen, nicht beim ersten bin, was blöde aussieht tomwalters@0: max_x_screen=border(2); tomwalters@0: minshowy=border(3); tomwalters@0: maxy=border(4); tomwalters@0: tomwalters@0: xvals=getxvalues(sig); tomwalters@0: % if we are dealing with milliseconds (very often), then the units are in tomwalters@0: % ms as well bleeck@3: % if strfind(sig.unit_x,'(ms)')>0 bleeck@3: % multiplier=1000; bleeck@3: % else tomwalters@0: multiplier=1; bleeck@3: % end tomwalters@0: tomwalters@0: tomwalters@0: xvals=xvals.*multiplier; tomwalters@0: yvals=getvalues(sig); tomwalters@0: bleeck@3: if ishandle(style) % ups, something gone wrong bleeck@3: style='b-'; bleeck@3: end bleeck@3: tomwalters@0: % this is the plotting command: bleeck@3: handle=plot(ax,xvals,yvals,style); tomwalters@0: tomwalters@0: if time_reversed tomwalters@0: set(ax,'XDir','reverse') % turn them around, because the higher values shell end on the right tomwalters@0: else tomwalters@0: set(ax,'XDir','normal') % normale ausrichtung tomwalters@0: end tomwalters@0: tomwalters@0: if is_log tomwalters@0: set(ax,'XScale','log') tomwalters@0: t=minimum_time*multiplier; tomwalters@0: tix=[t 2*t 4*t 8*t 16*t 32*t 64*t 128*t 256*t 512*t 1024*t]; tomwalters@0: if ~isempty(sig.x_tick_labels) tomwalters@0: ti=sig.x_tick_labels; tomwalters@0: set(ax,'XTicklabel',ti); tomwalters@0: end tomwalters@0: set(ax,'XTick',tix); tomwalters@0: else % its linear tomwalters@0: set(ax,'XScale','linear') tomwalters@0: end tomwalters@0: tomwalters@0: miny=border(3); tomwalters@0: maxy=border(4); tomwalters@0: y=[miny maxy]; tomwalters@0: if miny==maxy tomwalters@0: maxy=miny+1; tomwalters@0: miny=miny-1; tomwalters@0: end bleeck@3: try bleeck@3: set(ax,'xlim',[minimum_time*multiplier maximum_time*multiplier ]) bleeck@3: set(ax,'ylim',[miny*1.05 maxy*1.05]) bleeck@3: axis([minimum_time*multiplier maximum_time*multiplier miny*1.05 maxy*1.05]); bleeck@3: end tomwalters@0: tomwalters@0: tomwalters@0: xlabel(sig.unit_x); tomwalters@0: ylabel(sig.unit_y); tomwalters@0: title(sig.name,'Interpreter','none'); tomwalters@0: tomwalters@0: if nargout==1 tomwalters@0: rethandle=handle; tomwalters@0: end tomwalters@0: tomwalters@0: return