function [mittel]=plmeanx(x,y,Int,ixy,ipl,FARBE,varargin) % function [mittel]=plmeanx(x,y,Int,ixy,ipl,FARBE) % x,y sind die Eingabewerte fuer x und y % Int gibt die Intervalle an, in denen gemittelt werden soll, % bzw. bei Angabe von nur einem, positiven Wert ist dies die Anzahl der intervalle % bzw. bei nichts oder leer werden 10 Intervalle genommen % bzw. bei nur einem ,negativen Wert ist dies die Intervallbreite % je nach ixy werden mittelwerte und Std.abw geplottet. % ixy=-1,1,2 über die in Int angebenen Intervallen in X Mitteln % ixy=1 Std.abw. in Y richtung; ixy=2 in X-Richtung, ixy=-1 beide % ixy=-3,3,4 über die in Int angebenen Intervallen in Y Mitteln % ixy=3 Std.abw. in Y richtung; ixy=4 in X-Richtung, ixy=-3 beide % ixy kann auch ein Character-string von 1 oder 2 Zeichen sein, das % erste gibt die Achse des Intervalls, die Zweite der % Standardabweichung an. Bei nur einem Charcter werden beide % Standardabeichungen geplottet. Also "xx"=2, "yx"=4; "x"=-1 % je nach ipl wird geplottet: % ipl=1 nur Mittelwertkurve % ipl=2 nur Std.Abw. % ipl=sonst beides % % FARBE ist ein character String, erste character gibt die Farbe % fuer den Mittelwert, zweite den fuer die Standardabweichung % if FARBE ein 8-Zahlen Vektor so sind % 1-3 die RGB Werte fur den Mittelwert; 4=die Liniendicke % 5-7 die RGB Werte fur den Std.Abw.; 8=die Liniendicke % % Ist x=[] so wird als x 1:length(y) angenohmen, dito falls % nur ein Eingabeargument angegeben, d.h. plmeanx(y) % % Variable Arguments: % 'smooth' or 'glaetten' : this gives an additional width of the % intervall. With a positive numbers this means using % overlapping intervalls. (up till now this is also possible % given a intervall of two values, the first gives the % intervall in the normal form, the second the additional width. % if exist('Int')~=1; Int=[]; end if length(Int)==2; fglaetten=Int(2); Int=Int(1); else fglaetten=0; end ii=1; while ii <= nargin-6 switch lower(varargin{ii}) case {'smooth','glaetten'} ii=ii+1; if ii>nargin-6; error('smooth needs 2nd argument'); end fglaetten=varargin{ii}; otherwise error('unknown variable argument'); end ii=ii+1; end if nargin==1; y=x; x=[]; end if isempty(x); x=[1:length(y)]; end [xm,xn]=size(x);[ym,yn]=size(y); if xm~=ym & (xm==yn & xn==ym); y=y'; end if exist('ipl')~=1; ipl=0; end if isempty(ipl); ipl=0; end if exist('ixy')~=1; ixy=1; end if isempty(ixy); ixy=1; end if ischar(ixy) switch lower(ixy) case 'xx' ixy=2; case 'xy' ixy=1; case 'yy' ixy=3; case 'yx' ixy=4; case 'x' ixy=-1; case 'y' ixy=-3; otherwise error('wrong ixy argument') end end LWIDTHm=2 ; LWIDTHs=1; if exist('FARBE')~=1; FARBEm='r'; FARBEs='r'; elseif ischar(FARBE); FARBEm=FARBE(1); FARBEs=FARBEm; if length(FARBE)==2; FARBEs=FARBE(2); end else if length(FARBE)==8 FARBEm=FARBE(1:3); FARBEs=FARBE(5:7); LWIDTHm=FARBE(4) ; LWIDTHs=FARBE(8); else FARBEm='r'; FARBEs='r'; end end if isempty(Int); Int=10; end if length(Int)==1 if Int==0; Int=10; end if Int>0; if ixy==1 | ixy==2 | ixy==-1; Int=[min(x):(max(x)-min(x))/Int:max(x)]; else Int=[min(y):(max(y)-min(y))/Int:max(y)]; end else Int=abs(Int); if ixy==1 | ixy==2 | ixy==-1; Int=[floor(min(x)/Int)*Int:Int:ceil(max(x)/Int)*Int]; else Int=[floor(min(y)/Int)*Int:Int:ceil(max(y)/Int)*Int]; end end end HOLD=ishold; if ~HOLD; clf; hold on; end k=max(size(Int)); mittel=zeros(k-1,2); for i=1:k-1 if ixy==1 | ixy==2 | ixy==-1 ; j= x>=Int(i)-fglaetten & x<=Int(i+1)+fglaetten & ~isnan(y); else j= y>=Int(i)-fglaetten & y<=Int(i+1)+fglaetten & ~isnan(x); end if sum(j)>0 mittel(i,1)=mean(x(j)); mittel(i,2)=mean(y(j)); if ipl~=1 if ixy==1 | ixy==3 | ixy<0; r=std(x(j)); plot([mittel(i,1)-r mittel(i,1)+r],[mittel(i,2) mittel(i,2)],'color',FARBEs,... 'linewidth',LWIDTHs) end if ixy==2 | ixy==4 | ixy<0; r=std(y(j)); plot([mittel(i,1) mittel(i,1)],[mittel(i,2)-r mittel(i,2)+r],'color',FARBEs,... 'linewidth',LWIDTHs) end end else mittel(i,1)=NaN; mittel(i,2)=NaN; end end if ipl~=2; plot(mittel(:,1),mittel(:,2),'color',FARBEm,'linewidth',LWIDTHm); end if ~HOLD; hold off; end if nargout<1; clear mittel; end