contlimit_jd

PURPOSE ^

SYNOPSIS ^

function [x1c,x2c,col,lev] = contlimit_jd(x1d,x2d,fd,cont,cond,sfac)

DESCRIPTION ^

 This function gives the contour parametrization (x1c,x2c) calculated from
 the 2D data (x1d,x2d,fd) and contour number (or levels) cont, plotting
 the contours only in the 2D zone defined by cond(x1,x2)

 if cont

 by J. Decker (jodecker@alum.mit.edu) 10/11/04

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x1c,x2c,col,lev] = contlimit_jd(x1d,x2d,fd,cont,cond,sfac)
0002 %
0003 % This function gives the contour parametrization (x1c,x2c) calculated from
0004 % the 2D data (x1d,x2d,fd) and contour number (or levels) cont, plotting
0005 % the contours only in the 2D zone defined by cond(x1,x2)
0006 %
0007 % if cont
0008 %
0009 % by J. Decker (jodecker@alum.mit.edu) 10/11/04
0010 %
0011 if nargin < 6
0012     sfac = 1;
0013 end
0014 if nargin < 5
0015     cond = NaN;
0016 end
0017 if nargin < 4 || isempty(cont) || any(isnan(cont)),
0018     cont = 10;
0019 end
0020 %
0021 cont = cont(:);
0022 %
0023 fmin = min(min(fd));
0024 fmax = max(max(fd));
0025 %
0026 if length(cont) < 2 && cont ~= 0 && cont == round(cont),%number of contour is given
0027     cont = linspace(fmin,fmax,cont);
0028 else
0029     fmin = min(cont);
0030     fmax = max(cont);
0031 end
0032 %
0033 C = contourc(x1d,x2d,fd,cont);
0034 %
0035 if nargout > 2,
0036     cmap = colormap;
0037     clen = size(colormap,1);
0038     col = {};
0039 end
0040 %
0041 lnum = 0;
0042 x1c = {};
0043 x2c = {};
0044 while ~isempty(C)
0045     lnum = lnum + 1;
0046     tlen = size(C,2);
0047     lev(lnum) = C(1,1);
0048     len = C(2,1);
0049     line_1 = C(1,2:1+len);
0050     line_2 = C(2,2:1+len);
0051     %
0052     if len > 1,
0053         igrid = linspace(0,1,len);
0054         sgrid = linspace(0,1,(len-1)*sfac+1);
0055         line_1 = interp1(igrid,line_1,sgrid,'spline');
0056         line_2 = interp1(igrid,line_2,sgrid,'spline');
0057     end
0058     %
0059     if ischar(cond)
0060         eval(['mask = ',cond,'(line_1,line_2);']);
0061     elseif length(cond) == 4
0062         mask = line_1 >= cond(1) & line_1 <= cond(2) & line_2 >= cond(3) & line_2 <= cond(4);
0063     else
0064         mask = 1:len;
0065     end
0066     if nargout > 2,
0067         col{lnum} = cmap(1+round(((lev(lnum)-fmin)/(fmax-fmin))*(clen-1)),:);
0068     end
0069     x1c{lnum} = line_1(mask);
0070     x2c{lnum} = line_2(mask);
0071     C = C(:,len+2:tlen);
0072 end
0073 
0074 
0075 
0076 
0077 
0078 
0079

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.