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

📄 vsort.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [v2,pind]=vsort(v1,v2,sp)
% VSORT Matches two vectors.  Used in RLOCUS.
%	VS2 = VSORT(V1,V2) matches two complex vectors 
%	V1 and V2, returning VS2 with consists of the elements 
%	of V2 sorted so that they correspond to the elements 
%	in V1 in a least squares sense.

%     	[v2,pind]=VSORT(v1,v2,sp) 
%       sp is used to test a quick sort method and is equal to
%       sp=sum([1:length(indr)].^2); pind=1 is returned if
%       a slow sort method has to be applied.

%	Copyright (c) 1986-93, by the MathWorks, Inc.

pind=0;
if nargin < 3, sp = sum([1:length(v1)].^2); end
% Quick Sort 
p=length(v2);
vones=ones(p,1);
[dum,indr1]=min(abs(vones*v2.'-v1*vones'));
indr(indr1)=[1:p];

% Long (accurate) sort
if (indr*indr' ~= sp) 
	[dum,jnx]=sort(abs(v2));
	pind=1;
	for j=jnx' 
		[dum,inx]=min(abs(v2(j)-v1));
		indr(inx)=j;
		v1(inx)=1e30;
	end

end
v2=v2(indr);

⌨️ 快捷键说明

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