WEIB2DSTATPLOT Computes and plots the conditional mean and standard deviation CALL: weib2dstatplot(x1,x2,phat,res,sym); x1,x2 = data phat = [A1 B1 A2 B2 C12], i.e., 2D weibull parameters. res = resolution (default range(X2)/12) sym = {s1,s2,s3,s4} cell array of plot symbols for plotting empirical mean and standard deviation and theoretical mean and standard deviation, respectively. (default {'bo','rx','b-','r--'}) WEIB2DSTATPLOT plots the empirical conditional mean and standard deviation of X1 given X2 and optionally compares it with a 2D weibull distribution with parameters given in phat. Example phat = [1 2 1.5 1 .8]; [y1,y2] = weib2drnd(phat,1000,1); weib2dstatplot(y1,y2,phat); See also weib2dstat
Calculates the difference between the maximum and minimum values. | |
Mean and variance for the 2D Weibull distribution | |
Display message and abort function. | |
Get handle to current axis. | |
Hold current graph. | |
True for cell array. | |
Return hold state. | |
Linearly spaced vector. | |
Average or mean value. | |
Not-a-Number. | |
Linear plot. | |
Standard deviation. | |
Graph title. | |
X-axis label. |
001 function [ax11, h11, h22 ]=weib2dstatplot(V,H,phat,res,varargin) 002 % WEIB2DSTATPLOT Computes and plots the conditional mean and standard deviation 003 % 004 % CALL: weib2dstatplot(x1,x2,phat,res,sym); 005 % 006 % x1,x2 = data 007 % phat = [A1 B1 A2 B2 C12], i.e., 2D weibull parameters. 008 % res = resolution (default range(X2)/12) 009 % sym = {s1,s2,s3,s4} cell array of plot symbols for 010 % plotting empirical mean and standard deviation and 011 % theoretical mean and standard deviation, respectively. 012 % (default {'bo','rx','b-','r--'}) 013 % 014 % WEIB2DSTATPLOT plots the empirical conditional mean and standard 015 % deviation of X1 given X2 and optionally compares it with 016 % a 2D weibull distribution with parameters given in phat. 017 % 018 % Example 019 % phat = [1 2 1.5 1 .8]; 020 % [y1,y2] = weib2drnd(phat,1000,1); 021 % weib2dstatplot(y1,y2,phat); 022 % 023 % See also weib2dstat 024 025 % tested on matlab 5.2 026 % history: 027 % revised pab 03.11.2000 028 % changed var(tmp) to std(tmp)^2 029 % by Per A. Brodtkorb 23.11.98 030 031 %default values 032 sym = {'bo','rx','b-','r--'}; % default plot symbols for the empirical 033 % mean and std, and theoretical mean and 034 % std,respectivel 035 036 error(nargchk(2,8,nargin)) 037 if nargin<4|isempty(res), res=range(H(:))/12; end 038 Np=min(length(varargin),4); 039 if Np>0, 040 if Np>1 041 sym(1:Np)=varargin(1:Np); 042 elseif iscell(varargin{1}), 043 Np= min(length(varargin{1}),4); 044 sym(1:Np)=varargin{1}(1:Np); 045 end 046 end 047 grp=floor(H/res)+1; % dividing the data into groups 048 Ngrp=max(grp); 049 Nmesh=40; 050 h1=linspace(res/2, (Ngrp-0.5)*res, Ngrp)'; 051 %v1=linspace(eps,max(V),Nmesh)'; 052 h2=linspace(0, max(H), Nmesh)'; 053 054 055 m=h1;v=h1; 056 for ix=1:Ngrp, 057 tmp=V(grp==ix);%find data in group number ix 058 059 if length(tmp)>max(4,0),% if less than 4 observations in the group 060 m(ix)=mean(tmp); 061 v(ix)=std(tmp).^2; 062 else 063 m(ix)=NaN; 064 v(ix)=NaN; 065 end 066 end 067 068 ih = ishold; 069 plot(h1,m,sym{1},h1,sqrt(v),sym{2}); hold on 070 if ~isempty(phat), 071 [M1 V1]= weib2dstat(phat,2,h2); 072 plot(h2,M1,sym{3},h2,sqrt(V1),sym{4}), 073 end 074 if ~ih, hold off,end 075 076 title('Conditional mean and standard deviation') 077 xlabel('x2') 078 if nargout>0 079 ax11=gca; 080 end 081
Comments or corrections to the WAFO group