📄 symerr.m
字号:
function [num, rat] = symerr(x, y, tot)
%SYMERR Symbol error analysis.
% [NUMBER, RATIO] = SYMERR(X, Y) compares the elements in the two
% matrices X and Y. The number of the differences is outputted in
% NUMBER. The ratio of NUMBER to the dimension of Y is output in
% RATIO. When there is a matrix and there is a vector between X and
% Y, this function first converts the vector to a matrix with the
% column number same as the matrix one with each column has the same
% element, then proceeds with the computation.
%
% [NUMBER, RATIO] = SYMERR(X, Y, 'columnwise') specifies that the output
% NUMBER and RATIO are row vectors, which are the number and ratio for
% each columnwise comparison.
%
% See also BITERR.
% Wes Wang 1/14/94, 10/11/95.
% Copyright (c) 1995-96 by The MathWorks, Inc.
% $Revision: 1.1 $ $Date: 1996/04/01 18:03:59 $
[nx, mx] = size(x);
[ny, my] = size(y);
if (min(nx, mx) < 1) | (min(ny, my) < 1)
num = [];
rat = [];
return;
elseif (min(nx, mx) > 1) & (min(ny, my) > 1)
if (nx ~= ny) | (mx ~= my)
error('Dimentions must be agree.')
end;
else
if min(nx, mx) <= 1
x = x(:);
if (size(x, 1) ~= ny)
error('Dimentions must be agree.')
else
x = x * ones(1, my);
end;
elseif min(ny, my) <= 1
y = y(:);
if (size(y, 1) ~= nx)
error('Dimentions must be agree.')
else
y = y * ones(1, mx);
end;
[ny, my] = size(y);
else
error('Dimentions must be agree.')
end;
end;
z = abs(x - y);
if nargin <= 2
num = length(find(z ~= 0));
rat = num / (ny * my);
else
[indx, indy] = find(z ~= 0);
num = zeros(1, my);
for i = 1 : my
num(i) = sum(indy == i);
end;
num = num / ny;
end;
%--- end of symerr---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -