How do I compare two vectors of different length without interpolation?

44 views (last 30 days)
Hi everyone! I have 3 vectors that consist of photon heights from 3 different beams. Each vector has different lengths. I'm interested in comparing the variance of each beam with another beam (1&2, 2&3, 1&3) but I obviously cannot plot the beams against each other because of the different lengths. I do not want to interpolate the data because that would make me lose the variance. Is there any method where I could make the vectors the same length without interpolating?
  3 Comments
Walter Roberson
Walter Roberson on 15 Mar 2022
It is not clear then how you would like to compute the variance in the cases where different amounts of data are present.
Have you considered using nan to pad the datasets to the length of the largest dataset, and then using var() with the "omitnan" flag ?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 15 Mar 2022
Is there any method where I could make the vectors the same length without interpolating?
By definition: NO. Any method that gives a value at intermediate points is defined as being "interpolating". (Some interpolation methods are more useful than others.)
However, it does not matter. You can plot the beams in same figure, by using multiple axes if you need to. Of just don't label the axes and use linspace() to create x values so as to plot each of the vectors over the same width in the same axes.
You are not responsible for preserving correlation between features, since variance of a vector is a scalar value that is order-independent. As far as taking var() of a vector is concerned, it does not matter whether you var(x) or var(sort(x)) .
If you have a time axes and are trying to compare the variation point-by-point then the difference in lengths starts to be significant, but the method of proceeding would depend upon whether you are intended to keep fixed times scales, or if instead you are intended to find matching features.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by