shared-snippets/matlab/m2m/LinRegWrapper.m
2024-08-28 17:22:21 +02:00

33 lines
982 B
Matlab

%
% -----------------
% Copyright © 2019 ACK Cyfronet AGH, Poland.
%
% This work was partially funded by EPOS Project funded in frame of PL-POIR4.2
% --------------
%
function [msyn, outData, m1, m2] = LinRegWrapper(catalog, m1Type, m2Type, opt, n)
[m1, m2] = extractColumns(catalog, m1Type, m2Type);
[m1, m2] = eliminateEmptyValues(m1, m2);
if isLogarithmComparableToMagnitude(m1Type); m1 = log10(m1); end
if isLogarithmComparableToMagnitude(m2Type); m2 = log10(m2); end
if exist('OCTAVE_VERSION', 'builtin') > 0
[msyn, a, b, sa, sb, cc, rms, N] = LinReg_O(m1, m2, opt, n);
else
[msyn, a, b, sa, sb, cc, rms, N] = LinReg(m1, m2, opt, n);
end
outData.a = a;
outData.b = b;
outData.sa = sa;
outData.sb = sb;
outData.cc = cc;
outData.rms = rms;
outData.N = N;
end
function result = isLogarithmComparableToMagnitude(columnType)
result = strcmp(columnType, 'E') || strcmp(columnType, 'M0');
end