VC2SIGN Calculates ratio-significant value of the input vector. CALL: hs=vc2sign(H); hs=vc2sign(H,ratio); where hs = a three column matrix with 'ratio' in the first column, the ratio-significant value of H in the second, and a ratio-quantile in the third column. H = data vector. ratio = a constant (0<ratio<1) defining the significant value of the vector H. (optional input and only one significant value is computed). Example x = load('sea.dat'); [vcf,h] = dat2steep(x); % extract Crest front velocity and wave height. hs = vc2sign(h); plot(hs(:,1),hs(:,2)) xlabel('Ratio'),ylabel('Ratio-significant wave height.') hs3 = vc2sign(h,1/3); Hs = hs3(2) % significant wave height S = dat2spec(x); Hm0 = spec2char(S,'Hm0') % significant wave height from spectrum See also spec2char
Display message and abort function. |
001 function hs=vc2sign(H,ratio); 002 % VC2SIGN Calculates ratio-significant value of the input vector. 003 % 004 % CALL: hs=vc2sign(H); 005 % hs=vc2sign(H,ratio); 006 % where 007 % 008 % hs = a three column matrix with 'ratio' in the first column, 009 % the ratio-significant value of H in the second, and 010 % a ratio-quantile in the third column. 011 % H = data vector. 012 % ratio = a constant (0<ratio<1) defining the significant 013 % value of the vector H. (optional input and only one 014 % significant value is computed). 015 % 016 % Example 017 % x = load('sea.dat'); 018 % [vcf,h] = dat2steep(x); % extract Crest front velocity and wave height. 019 % hs = vc2sign(h); 020 % plot(hs(:,1),hs(:,2)) 021 % xlabel('Ratio'),ylabel('Ratio-significant wave height.') 022 % hs3 = vc2sign(h,1/3); 023 % Hs = hs3(2) % significant wave height 024 % S = dat2spec(x); 025 % Hm0 = spec2char(S,'Hm0') % significant wave height from spectrum 026 % 027 % See also spec2char 028 029 Hs=sort(H); 030 test=size(Hs); 031 032 if test(1)>1 033 Hs=Hs'; 034 end 035 036 N=length(Hs); 037 038 if (nargin<2) 039 hs=ones(N,3); 040 041 hs(:,2)=flipud(cumsum(flipud(Hs'))); 042 043 hs(:,2)=hs(:,2)./flipud([1:N]'); 044 hs(:,1)=1-[0:N-1]'/N; 045 hs(:,3)=Hs'; 046 else 047 if ratio <= 0 048 error('ratio must be >0.') 049 end 050 051 if ratio > 1 052 error('ratio must be <=1.') 053 end 054 055 N3=ceil((1-ratio)*N); 056 hs=[ratio sum(Hs(N3:N))/(N-N3+1)]; 057 end 058
Comments or corrections to the WAFO group