v_imagescnu

PURPOSE ^

Plot image with non-uniform rectangular patches

SYNOPSIS ^

function v_imagescnu(x,y,v,db)

DESCRIPTION ^

 Plot image with non-uniform rectangular patches

  Usage:   v_imagescnu(log10(1:2:9),pow2(1:3),reshape(1:15,3,5));
           colorbar;

  Inputs:  x(nx) or x(nx+1)    x-axis patch centres or boundaries
           y(ny) or y(ny+1)    y-axis patch centres or boundaries
           v(ny,nx)            Values to plot
           db                  dB range to plot relative to peak (+ve for mag, -ve for power, 0 [default] for linear)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function v_imagescnu(x,y,v,db)
0002 % Plot image with non-uniform rectangular patches
0003 %
0004 %  Usage:   v_imagescnu(log10(1:2:9),pow2(1:3),reshape(1:15,3,5));
0005 %           colorbar;
0006 %
0007 %  Inputs:  x(nx) or x(nx+1)    x-axis patch centres or boundaries
0008 %           y(ny) or y(ny+1)    y-axis patch centres or boundaries
0009 %           v(ny,nx)            Values to plot
0010 %           db                  dB range to plot relative to peak (+ve for mag, -ve for power, 0 [default] for linear)
0011 %
0012 if nargin<4
0013     db=0;               % default to linear scale
0014 end
0015 [ny,nx]=size(v);
0016 x=x(:)';                % make x a row vector
0017 y=y(:)';                % make y a row vector
0018 if length(x)==nx
0019     if nx==1
0020         x=-0.5:0.5;
0021     else
0022         x=0.5*[3*x(1)-x(2) x(1:nx-1)+x(2:nx) 3*x(nx)-x(nx-1)];
0023     end
0024 elseif length(x)~=nx+1
0025     error('size(v)=(%d,%d) so length(x) must be %d or %d',ny,nx,nx,nx+1);
0026 end
0027 if any(x(2:nx+1)-x(1:nx)<=0)
0028     error('x values must be monotonically increasing');
0029 end
0030 if length(y)==ny
0031     if ny==1
0032         y=-0.5:0.5;
0033     else
0034         y=0.5*[3*y(1)-y(2) y(1:ny-1)+y(2:ny) 3*y(ny)-y(ny-1)];
0035     end
0036 elseif length(y)~=ny+1
0037     error('size(v)=(%d,%d) so length(y) must be %d or %d',ny,nx,ny,ny+1);
0038 end
0039 if any(y(2:ny+1)-y(1:ny)<=0)
0040     error('y values must be monotonically increasing');
0041 end
0042 if db~=0
0043     v=abs(v);
0044     dbmul=(db>0)*10+10;
0045     v=dbmul*log10(max(v,max(v(:))*10^(-abs(db)/dbmul)));
0046 end
0047 ix=reshape(repmat(1:nx,ny,1),1,nx*ny);
0048 iy=reshape(repmat((1:ny),1,nx),1,nx*ny);
0049 patx=[x(ix);x(ix+1);x(ix+1);x(ix)];
0050 paty=[y(iy);y(iy);y(iy+1);y(iy+1)];
0051 clf;
0052 patch(patx,paty,v(:),'EdgeColor', 'none');
0053 axis([x(1) x(nx+1) y(1) y(ny+1)]);
0054 axis ij; % to conform to imagesc()

Generated by m2html © 2003