SPWAVEPLOT Plots specified waves from a timeseries CALL: spwaveplot(x1,x2,w_ind,tz_ind,sym1,sym2) x1,x2 = two-column timeseries first column sampling times [sec] second column surface elevation [m] w_ind = vector of indices to waves we want to plot, i.e., wave numbers. tz_ind = vector of indices to the beginning, middle and end of defining wave, i.e. for zero-downcrossing waves, indices to zerocrossings (default trough2trough wave) sym1, sym2 = plot symbol and color for x1 and x2, respectively (see PLOT) (default 'k-' and 'k+') Note: - sym1 and sym2 can be given anywhere after x1. if omitted default values are used. - x2 can be omitted, but if given it must appear before the vectors w_ind, tz_ind Example: Plot waves nr. 6,7,8 and waves nr. 12,13,...,17 x = load('sea.dat'); x1 = x(1:500,:); spwaveplot(x1,[6:8 12:17]) See also waveplot, dat2tc
Extracts troughs and crests from data. | |
Control axis scaling and appearance. | |
Difference and approximate derivative. | |
Display message and abort function. | |
Create figure window. | |
Get handle to current figure. | |
Hold current graph. | |
Convert integer to string (Fast version). | |
True for character array (string). | |
Linear plot. | |
Create axes in tiled positions. | |
X-axis label. | |
Y-axis label. |
% CHAPTER3 Demonstrates distributions of wave characteristics |
001 function spwaveplot(xx,varargin) 002 %SPWAVEPLOT Plots specified waves from a timeseries 003 % 004 % CALL: spwaveplot(x1,x2,w_ind,tz_ind,sym1,sym2) 005 % 006 % x1,x2 = two-column timeseries 007 % first column sampling times [sec] 008 % second column surface elevation [m] 009 % 010 % w_ind = vector of indices to waves we want to plot, i.e., wave numbers. 011 % tz_ind = vector of indices to the beginning, middle and end of 012 % defining wave, i.e. for zero-downcrossing waves, indices to 013 % zerocrossings (default trough2trough wave) 014 % sym1, sym2 = plot symbol and color for x1 and x2, respectively 015 % (see PLOT) (default 'k-' and 'k+') 016 % 017 % Note: - sym1 and sym2 can be given anywhere after x1. 018 % if omitted default values are used. 019 % - x2 can be omitted, but if given it must appear 020 % before the vectors w_ind, tz_ind 021 % 022 % Example: Plot waves nr. 6,7,8 and waves nr. 12,13,...,17 023 % x = load('sea.dat'); x1 = x(1:500,:); 024 % spwaveplot(x1,[6:8 12:17]) 025 % 026 % See also waveplot, dat2tc 027 028 % Tested on: Matlab 6.0, 5.3, 5.2, 5.1 029 % History: 030 % revised jr 02.04.2001 031 % - updated example, documentation 032 % revised pab 24.05.2000 033 % - improved order of input arguments 034 % - improved w_ind and plotting 035 % revised pab 03.12.1999 036 % - updated documentation 037 % by pab 11.08.99 038 039 [xx2,Nsub,Nfig,Nwp,w_ind,tz_ind,sym1,sym2] = wavechk(varargin,xx); 040 041 042 for iy=1:Nfig 043 for ix=1:Nsub, 044 subplot(Nsub,1,mod(ix-1,Nsub)+1) 045 ind= tz_ind(2*w_ind(ix)-1):tz_ind(2*w_ind(ix)+2*Nwp(ix)); % indices to wave 046 plot(xx(ind,1),xx(ind,2),sym1);hold on %plot wave 047 plot(xx([ind(1) ind(end)],1),[0 0]), % plot zero level 048 049 if ~isempty(xx2) 050 ax = axis; 051 axis([xx([ind(1) ind(end)],1)' ax(3:4)]) %make sure the axis does not change 052 plot(xx2(:,1),xx2(:,2),sym2) % before we plot xx2 on top 053 end 054 hold off 055 if Nwp(ix)==1, 056 ylabel(['Wave ', int2str(w_ind(ix))]) 057 else 058 ylabel(['Wave ', int2str(w_ind(ix)) '-' int2str(w_ind(ix)+Nwp(ix)-1)]) 059 end 060 061 end % Nsub 062 xlabel('Time (sec)'); 063 if (mod(ix-1,Nsub)+1==Nsub)& iy~=Nfig, figure(gcf+1); end 064 end % Nfig 065 066 067 function [x2,Nsub,Nfig,Nwp,w_ind,tz_ind,sym1,sym2] = wavechk(P,x1) 068 %WAVECHK Helper function for spwaveplot. 069 % 070 % CALL [x2, Nsub,Nf,w_ind,tz_ind,sym1,sym2]=wavechk(P,x1) 071 % 072 % P = the cell array P of input arguments (between 0 and 7 elements) 073 % x1 = must be a two column vector. 074 075 076 077 Np=length(P); 078 strix=zeros(1,Np); 079 for ix=1:Np, % finding symbol strings 080 strix(ix)=ischar(P{ix}); 081 end 082 sym1='k-'; % Black line is default 083 sym2='k+'; % Black plus is default 084 k=find(strix); 085 if any(k) 086 sym1=P{k(1)}; 087 Np=Np-1; 088 if length(k)>1 089 sym2=P{k(2)}; 090 Np=Np-1; 091 end 092 P={P{find(~strix)}}; 093 end 094 095 096 x2=[]; 097 098 if (Np>0) & (all(size(P{1})>1)) 099 x2=P{1}; 100 P={P{2:Np}}; 101 Np=Np-1; 102 end 103 104 if (Np >= 1) & ~isempty(P{1}) 105 % waveplot(x1,x2,Nsub) 106 w_ind=P{1}; 107 else 108 error('w_ind must be given') 109 end 110 111 if (Np >= 2) & ~isempty(P{2}) 112 tz_ind=P{2}; 113 else 114 %indmiss=isnan(x1(:,2)); % indices to missing points 115 [tc tc_ind,tz_ind]=dat2tc(x1,0,'tw'); % finding trough to trough waves 116 end 117 118 Nw = length(w_ind);%# waves 119 dw = find([0;abs(diff(w_ind(:)))>1]); 120 Nsub =length(dw)+1; 121 Nwp=zeros(1,Nsub); 122 if Nsub>1 123 Nwp(Nsub)= w_ind(end)-w_ind(dw(end))+1; 124 w_ind(dw(end)+1:end)=[]; 125 for ix=Nsub-2:-2:1 126 Nwp(ix+1) = w_ind(dw(ix+1)-1)-w_ind(dw(ix))+1; % # of waves pr subplot 127 w_ind(dw(ix)+1:dw(ix+1)-1)=[]; 128 end 129 Nwp(1)= w_ind(dw(1)-1)-w_ind(1)+1; 130 w_ind(2:dw(1)-1)=[]; 131 else 132 Nwp(1)= w_ind(end)-w_ind(1)+1; 133 end 134 135 Nsub=min(6,Nsub); 136 Nfig=ceil(Nsub/6); 137 Nsub=min(6,ceil(Nsub/Nfig)); 138 139
Comments or corrections to the WAFO group