⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mminterp.m

📁 关于MATLAB的一些指导和大量的实例 !
💻 M
字号:
function y=mminterp(tab,col,val)%MMINTERP 1-D Table Search by Linear Interpolation.% Y=MMINTERP(TAB,COL,VAL) linearly interpolates the table% TAB searching for the scalar value VAL in the column COL.% All crossings are found and TAB(:,COL) need not be monotonic.% Each crossing is returned as a separate row in Y and Y has as% many columns as TAB. Naturally, the column COL of Y contains% the value VAL. If VAL is not found in the table, Y=[].% D.C. Hanselman, University of Maine, Orono ME,  04469% 1/26/94% Copyright (c) 1996 by Prentice-Hall, Inc. [rt,ct]=size(tab);if length(val)>1, error('VAL must be a scalar.'), endif col>ct|col<1,  error('Chosen column outside table width.'), endif rt<2, error('Table too small or not oriented in columns.'), endabove=tab(:,col)>val;below=tab(:,col)<val;equal=tab(:,col)==val;if all(above==0)|all(below==0), % handle simplest case	y=tab(find(equal),:);	returnendpslope=find(below(1:rt-1)&above(2:rt)); %indices where slope is posnslope=find(below(2:rt)&above(1:rt-1)); %indices where slope is negib=sort([pslope;nslope+1]);	% put indices below in orderia=sort([nslope;pslope+1]);	% put indices above in orderie=find(equal);				% indices where equal to val[tmp,ix]=sort([ib;ie]);		% find where equals fit in resultieq=ix>length(ib);			% True where equals values fitry=length(tmp);				% # of rows in result yy=zeros(ry,ct);				% poke data into a zero matrixalpha=(val-tab(ib,col))./(tab(ia,col)-tab(ib,col));alpha=alpha(:,ones(1,ct));y(~ieq,:)=alpha.*tab(ia,:)+(1-alpha).*tab(ib,:);	% interpolated valuesy(ieq,:)=tab(ie,:);			% equal valuesy(:,col)=val*ones(ry,1);	% remove roundoff error

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -