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

📄 mmfind.m

📁 关于MATLAB的一些指导和大量的实例 !
💻 M
字号:
function m=mmtest(a,b,c)%MMFIND Intersection of Elements in Two Matrices.% MMFIND(A,B) returns a logical matrix the size of A% having ones where the corresponding elements of A% also appear in B. A and B need not be the same size.% This function shows how vectorizing using index manipulations% is faster than repeated interpretation of statements in a loop% even when many more flops are involved.%% For comparison and illustration MMFIND(A,B,1) uses a FOR loop% to compute the result.% D.C. Hanselman, University of Maine, Orono, ME, 04469% 8/24/95% Copyright (c) 1996 by Prentice-Hall, Inc.b=sort(b(:));b(~[diff(b);1])=[];         % discard duplicate values in b[ra,ca]=size(a);m=zeros(ra,ca);             % make output mask vector of FALSEa=a(:);                     % convert to column vectorna=length(a);if nargin==3                % due slow way, comment out if you wish	for i=1:na		m(i)=any(a(i)==b);	end	returnend[sa,ia]=sort(a);            % sort to look for duplicates in ad=[~diff(sa);0];            % true where duplicates exist in sa ida=ia(d);                  % indices of duplicates in afor i=ida.'	m(i)=any(a(i)==b);      % check duplicates and poke in TRUEenda(ida)=nan*ones(length(ida),1);% change duplicates to nan                               % nan's go to end when sorted[x,ix]=sort([a;b]);     % sort a and b togetherdx=[diff(x);1];         % look for differencesi=ix(dx==0);            % indices of a that have matching values in bm(i)=ones(length(i),1); % poke TRUE into these indices

⌨️ 快捷键说明

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