L
L
LLlmoster2016-06-06 18:32:50
Mathematics
LLlmoster, 2016-06-06 18:32:50

How to compare two vectors? Different sizes?

Hello,
I ask you to help with the search for a comparison method.
There is
1) a set of readings from a certain sensor over a long period of time. Readings are taken every minute.
2) A certain pattern of readings that reports a critical situation, which is a set of sensor values ​​for 5 minutes, i.e. (val1,val2,val3,val4,val5)
A critical situation is when the sensor readings for the last 5 minutes match the template with some error. To compare the data for the last 5 minutes with the template, I use the least squares method (LSM).
However, a situation similar to the template can be reproduced both at 4 minutes and at 6 and - when one of the template values ​​val is shorter / longer in time, for example.
The question is - how can one compare vectors of dimensions N and N-1 or N and N-2 by analogy with LSM?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Skusnov, 2016-06-07
@AlexSku

MatLab has a subspace(A, B) function that calculates a linear relationship (angle) between vectors of different dimensions. I don't know if it will work, but here is its code:

% Compute orthonormal bases, using SVD in "orth" to avoid problems
% when A and/or B is nearly rank deficient.
A = orth(A);
B = orth(B);
%Check rank and swap
if size(A,2) < size(B,2)
   [A,B] = swap(A,B); 
end
% Compute the projection according to [1].
B = B - A*(A'*B);
% Make sure it's magnitude is less than 1.
theta = asin(min(ones(superiorfloat(A,B)),norm(B)));
end

function [B, A] = swap(A, B)
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question