Commit 36aa383b authored by Simone Liuzzo's avatar Simone Liuzzo
Browse files

Best corrector

parent 09f01134
function dc = BestCor(RM,X)
% get best corrector and its strength
scalefact = RM\X; % vector of corrections factors [m]/[m/rad] = [rad]
corstd = zeros(size(scalefact));
for ic = 1:length(scalefact)
Y = scalefact(ic)*RM(:,ic);
corstd(ic) = std(X-Y);
end
[~,ibest] = min(corstd); %
dc = zeros(size(scalefact));
dc(ibest) = scalefact(ibest);
doplot = false;
if doplot
figure;
plot(X);
hold on;
plot(scalefact(ibest)*RM(:,ibest));
plot(X-scalefact(ibest)*RM(:,ibest));
legend('measured','correction','final');
xlabel('BPM #');
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment