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

📄 isequal.m

📁 HERE IS A GOOD PSO TOOL BOX
💻 M
字号:
function r = isequal(m1, m2)% MONOMIAL/ISEQUAL  Checks if two monomials are equal.% Example: x*y and y*x are equal.%% make sure both are monomialsm1 = monomial(m1);m2 = monomial(m2);% assume true state (monomials are equal)r = 1; % first check if they have same number of gpvarsif( length(m1.gpvars) ~= length(m2.gpvars) )  r = 0; % monomials cannot be equal  return;end% check that both have the same variablesif ~isempty(setdiff(m1.gpvars, m2.gpvars))  r = 0; % monomials cannot be equal  return;end% now check that both have the same exponentsfor k = 1:length(m1.gpvars)  [tf, loc] = ismember( m1.gpvars{k}, m2.gpvars );  % check the variable exponents  if( m1.a(k) ~= m2.a(loc) )    r = 0; % monomial are not equal    return;  endend

⌨️ 快捷键说明

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