Home > wafo > cycles > cmatplot.m

cmatplot

PURPOSE ^

Plots a cycle matrix, e.g. a rainflow matrix.

SYNOPSIS ^

cmatplot(in1,in2,in3,in4,in5)

DESCRIPTION ^

 CMATPLOT Plots a cycle matrix, e.g. a rainflow matrix.
 
  CALL:  cmatplot(F)
         cmatplot(F,method)
         cmatplot(ux,uy,F)
         cmatplot(ux,uy,F,method)
  
  F      = Cycle matrix (e.g. rainflow matrix) [nxm]
  method = 1: mesh-plot (default)
           2: surf-plot
           3: pcolor-plot    [axis('square')]
           4: contour-plot   [axis('square')]
           5: TechMath-plot  [axis('square')]
           11: From-To, mesh-plot
           12: From-To, surf-plot
           13: From-To, pcolor-plot   [axis('square')]
           14: From-To, contour-plot  [axis('square')]
           15: From-To, TechMath-plot [axis('square')]
  ux     = x-axis (default: 1:m)
  uy     = y-axis (default: 1:n)
 
  Examples:
    param = [-1 1 64]; u=levels(param);
    F = mktestmat(param,[-0.2 0.2],0.25,1/2);
    cmatplot(F,1)
    cmatplot(u,u,F,2), colorbar
    cmatplot(u,u,F,3), colorbar
    cmatplot(u,u,F,4)
 
  See also  cocc, ccplot

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function cmatplotcmatplot(in1,in2,in3,in4,in5)
0002 %CMATPLOT Plots a cycle matrix, e.g. a rainflow matrix.
0003 %
0004 % CALL:  cmatplot(F)
0005 %        cmatplot(F,method)
0006 %        cmatplot(ux,uy,F)
0007 %        cmatplot(ux,uy,F,method)
0008 % 
0009 % F      = Cycle matrix (e.g. rainflow matrix) [nxm]
0010 % method = 1: mesh-plot (default)
0011 %          2: surf-plot
0012 %          3: pcolor-plot    [axis('square')]
0013 %          4: contour-plot   [axis('square')]
0014 %          5: TechMath-plot  [axis('square')]
0015 %          11: From-To, mesh-plot
0016 %          12: From-To, surf-plot
0017 %          13: From-To, pcolor-plot   [axis('square')]
0018 %          14: From-To, contour-plot  [axis('square')]
0019 %          15: From-To, TechMath-plot [axis('square')]
0020 % ux     = x-axis (default: 1:m)
0021 % uy     = y-axis (default: 1:n)
0022 %
0023 % Examples:
0024 %   param = [-1 1 64]; u=levels(param);
0025 %   F = mktestmat(param,[-0.2 0.2],0.25,1/2);
0026 %   cmatplot(F,1)
0027 %   cmatplot(u,u,F,2), colorbar
0028 %   cmatplot(u,u,F,3), colorbar
0029 %   cmatplot(u,u,F,4)
0030 %
0031 % See also  cocc, ccplot
0032 
0033 % Tested on Matlab 6.0 
0034 %
0035 % 1997-10-22  PJ  Korrigerat pcolor-plot. Ritar nu rätt antal rutor.
0036 % 1998-11-03  PJ  Method 5
0037 % Copyright (c) 1997 by Pär Johannesson
0038 % Toolbox: Rainflow Cycles for Switching Processes V.1.0, 2-Oct-1997
0039 % Check input arguments
0040 
0041 ni = nargin;
0042 no = nargout;
0043 error(nargchk(1,5,ni));
0044 
0045 if ni == 1     % cmatplot(F)
0046   F=in1;
0047   method=[];
0048   ux=[]; uy=[];
0049   clevels=[];
0050 elseif ni == 2 % cmatplot(F,method)
0051   F=in1;
0052   method = in2;
0053   ux=[]; uy=[];
0054   clevels=[];
0055 elseif ni == 3 % cmatplot(ux,uy,F)
0056   ux=in1;
0057   uy=in2;
0058   F=in3;
0059   method=[];
0060   clevels=[];
0061 elseif ni == 4 % cmatplot(ux,uy,F,method)
0062   ux=in1;
0063   uy=in2;
0064   F=in3;
0065   method=in4;
0066   clevels=[];
0067 elseif ni == 5 % cmatplot(ux,uy,F,method,clevels)
0068   ux=in1;
0069   uy=in2;
0070   F=in3;
0071   method=in4;
0072   clevels=in5;
0073 else
0074   error('Wrong number of input arguments.');
0075 end
0076 
0077 if isempty(method)  % Default method
0078   method = 1;
0079 end
0080 
0081 
0082 % Vrid cykelmatrisen för att plotta rätt
0083 %F = flipud(F');
0084 
0085 
0086 % If F is a cell-array, then plot each cell in a subplot
0087 if iscell(F)
0088   [N,M] = size(F);
0089   for i=1:N
0090     for j=1:M
0091       subplot(N,M,(i-1)*M+j)
0092       cmatplot(ux,uy,F{i,j},method,clevels);
0093     end
0094   end
0095   
0096 else
0097 
0098 if isempty(ux)
0099   ux =(1:size(F,2));  % Antalet kolumner
0100 end
0101 if isempty(uy)
0102   uy =(1:size(F,1));  % Antalet rader
0103 end
0104 
0105 % Make sure ux and uy are row vectors
0106 ux = ux(:)'; 
0107 uy = uy(:)';
0108 
0109 n = length(F);
0110       
0111 if method == 1      % mesh
0112   F = flipud(F');% Vrid cykelmatrisen för att plotta rätt
0113   mesh(ux,fliplr(uy),F)
0114   xlabel('min')
0115   ylabel('Max')
0116   view(-37.5-90,30)
0117   v = axis; axis([min(ux) max(ux) min(uy) max(uy) v(5:6)]);
0118 elseif method == 2  % surf
0119   F = flipud(F');% Vrid cykelmatrisen för att plotta rätt
0120   surf(ux,fliplr(uy),F)
0121   xlabel('min')
0122   ylabel('Max')
0123   view(-37.5-90,30)
0124   v = axis; axis([min(ux) max(ux) min(uy) max(uy) v(5:6)]);
0125 elseif method == 3  % pcolor
0126   F = flipud(F');% Vrid cykelmatrisen för att plotta rätt
0127   F1 = [F zeros(length(uy),1); zeros(1,length(ux)+1)];
0128   F2 = F1; F2(F2==0)=NaN;
0129   F1 = F2;
0130   dx=ux(2)-ux(1); dy=uy(2)-uy(1);
0131   ux1 = [ux ux(length(ux))+dx] - dx/2;
0132   uy1 = [uy uy(length(uy))+dy] - dy/2;
0133   pcolor(ux1,fliplr(uy1),F1)
0134   xlabel('min')
0135   ylabel('Max')
0136   v = axis; axis([min(ux1) max(ux1) min(uy1) max(uy1)]);
0137   axis('square')
0138 elseif method == 4  % contour
0139   F = flipud(F');% Vrid cykelmatrisen för att plotta rätt
0140   if isempty(clevels)
0141     Fmax=max(max(F));
0142     clevels=Fmax*[0.005 0.01 0.02 0.05 0.1 0.2 0.4 0.6 0.8];
0143   end
0144   contour(ux,fliplr(uy),F,clevels)
0145   xlabel('min')
0146   ylabel('Max')
0147   v = axis; axis([min(ux) max(ux) min(uy) max(uy)]);
0148   axis('square')
0149   % Skriv höjden på konturlinjerna. (Kopia från WAT.)
0150 %  Cstr=num2str(clevels(1),4);
0151 %  for i=2:length(clevels)
0152 %    Cstr=[Cstr ',' num2str(clevels(i),4)];
0153 %  end
0154 %  title(['ISO-lines: ' Cstr])
0155 
0156 if 1==2
0157   clevels=sort(clevels);
0158   n_clevels=length(clevels);
0159   if n_clevels>12
0160     disp('   Only the first 12 levels will be listed in table.')
0161     n_clevels=12;
0162   end
0163 
0164   textstart_x=0.65;
0165   textstart_y=0.45;
0166   delta_y=1/33;
0167   h=figtext(textstart_x,textstart_y,'Level curves at:','norm');
0168   set(h,'FontWeight','Bold')
0169 
0170   textstart_y=textstart_y-delta_y;
0171 
0172   for i=1:n_clevels
0173     textstart_y=textstart_y-delta_y;
0174     figtext(textstart_x,textstart_y,num2str(clevels(i)),'norm')
0175   end
0176 end % 1==2
0177 
0178 elseif method == 5 |  method == 15 % TechMath-typ
0179 
0180   if isempty(clevels)
0181     Fmax=max(max(F));
0182     clevels=Fmax*[0.001 0.005 0.01 0.05 0.1 0.5 1.0];
0183   end
0184   v=clevels;
0185 %  axis('ij');
0186   sym = '...x+***';
0187   sz = [6 20 24 8 8 8 12 16]
0188   
0189 %  plot(-1,-1,sym(1),'markersize',1),hold on
0190   for i = 1:length(v)
0191     plot(-1,-1,sym(i),'markersize',sz(i)),hold on
0192   end
0193   
0194   for i = 1:length(v)-1
0195     Ind = (F>v(i)) & (F<=v(i+1));
0196     [I,J] = find(Ind);
0197 %    axis('ij');
0198     plot(I,J,sym(i),'markersize',sz(i)),hold on
0199   end
0200   plot([1 n],[1 n],'--'), grid
0201   hold off
0202 
0203   axis([0.5 n+0.5 0.5 n+0.5])
0204 
0205   %legendText = sprintf('%6g < f <= %6g\n',[v(1:nv-1); v(2:nv)])
0206   %legendText = sprintf('<= %g\n',v(2:end))
0207 
0208   legendText=num2str(v(1:end)')
0209 
0210   legend(legendText,-1)
0211   
0212   title('From-To plot')
0213   xlabel('To / Standing')
0214   ylabel('From / Hanging')
0215   
0216   if method == 15
0217     axis('ij');
0218   end
0219   
0220 elseif method == 11  % mesh
0221   
0222   mesh(ux,uy,F)
0223   axis('ij');
0224   xlabel('To')
0225   ylabel('From')
0226   view(-37.5-90,30)
0227   v = axis; axis([min(ux) max(ux) min(uy) max(uy) v(5:6)]);
0228   
0229 elseif method == 12  % surf
0230   
0231   surf(ux,uy,F)
0232   axis('ij');
0233   xlabel('To')
0234   ylabel('From')
0235   view(-37.5-90,30)
0236   v = axis; axis([min(ux) max(ux) min(uy) max(uy) v(5:6)]);
0237   
0238 elseif method == 13  % From-To-Matrix - pcolor
0239   
0240   F1 = [F zeros(length(uy),1); zeros(1,length(ux)+1)];
0241   F2 = F1; F2(F2==0)=NaN;
0242   F1 = F2;
0243   dx=ux(2)-ux(1); dy=uy(2)-uy(1);
0244   ux1 = [ux ux(length(ux))+dx] - dx/2;
0245   uy1 = [uy uy(length(uy))+dy] - dy/2;
0246   axis('ij');
0247   pcolor(ux1,uy1,F1)
0248   axis('ij');
0249   xlabel('To')
0250   ylabel('From')
0251   v = axis; axis([min(ux1) max(ux1) min(uy1) max(uy1)]);
0252   axis('square')
0253   
0254 elseif method == 14  % contour
0255   if isempty(clevels)
0256     Fmax=max(max(F));
0257     clevels=Fmax*[0.005 0.01 0.02 0.05 0.1 0.2 0.4 0.6 0.8];
0258   end
0259   contour(ux,uy,F,clevels)
0260   axis('ij');
0261   xlabel('To')
0262   ylabel('From')
0263   v = axis; axis([min(ux) max(ux) min(uy) max(uy)]);
0264   axis('square')
0265   % Skriv höjden på konturlinjerna. (Kopia från WAT.)
0266 %  Cstr=num2str(clevels(1),4);
0267 %  for i=2:length(clevels)
0268 %    Cstr=[Cstr ',' num2str(clevels(i),4)];
0269 %  end
0270 %  title(['ISO-lines: ' Cstr])
0271 
0272   if 1==1 % Skriv ut höjden på nivåkurverna.
0273     clevels=sort(clevels);
0274     n_clevels=length(clevels);
0275     if n_clevels>12
0276       disp('   Only the first 12 levels will be listed in table.')
0277       n_clevels=12;
0278     end
0279 
0280     textstart_x=0.10;
0281     textstart_y=0.45;
0282     delta_y=1/33;
0283     h=figtext(textstart_x,textstart_y,'Level curves at:','norm');
0284     set(h,'FontWeight','Bold')
0285 
0286     textstart_y=textstart_y-delta_y;
0287 
0288     for i=1:n_clevels
0289       textstart_y=textstart_y-delta_y;
0290       figtext(textstart_x,textstart_y,num2str(clevels(i)),'norm')
0291     end
0292   end
0293 
0294 elseif method == 15  % TechMath-typ
0295 % See: 'method == 5'
0296 
0297 %  if isempty(clevels)
0298 %    Fmax=max(max(F));
0299 %    clevels=Fmax*[0.005 0.01 0.05 0.1 0.4 0.8];
0300 %  end
0301 %  v=clevels;
0302 %  axis('ij');
0303 %  sym = '...***';
0304 %  sz = [8 12 16 8 12 16]
0305 %  for i = 1:length(v)-1
0306 %    Ind = (F>v(i)) & (F<=v(i+1));
0307 %    [I,J] = find(Ind);
0308 %    axis('ij');
0309 %    plot(J,I,sym(i),'markersize',sz(i)),hold on
0310 %  end
0311 %  hold off
0312 %
0313 %  axis([0.5 n+0.5 0.5 n+0.5])
0314 %
0315 %  %legendText = sprintf('%6g < f <= %6g\n',[v(1:nv-1); v(2:nv)])
0316 %  legendText = sprintf('<= %g\n',v(2:nv))
0317 %
0318 %  %legendText=num2str(v(2:nv)')
0319 %
0320 %  legend(legendText,-1)
0321 
0322 end
0323 
0324 end % if iscell(F)
0325

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003