How can I find the difference between two graphs with size mismatch?
I have a question that I don't know if there is a straight forward solution.
Here he goes,
I have two datasets plotted on the same drawing. I need to find their difference, simple so far ... the
problem is that, say, the matrix A
has 1000 data points and the second (matrix B
) has 580 data points. How can I find the difference between the two graphs since there is a size overlap between the two numbers.
One way I was thinking artificially inflates matrix B to 1000 data points, but the trend of the graph will remain the same. Is it possible? And if so, how?
eg:
A=[1 45 33 4 1009 ]; B=[1 22 33 44 55 66 77 88 99 1010]; Ya=A.*20+4; Yb=B./10+3; C=abs(B - A) plot(A,Ya,'r',B,Yb) xlim([-100 1000]) grid on hold on plot(length(B),C)
source to share
One way to do this is to reshape the 580 vector element into 1000 samples. Use matlab resample
(for this I, in my opinion, requires a Signal Processing Tool):
x = randn(580,1);
y = randn(1000,1);
xr = resample(x, 50,29); # 50/29 = 1000/580 is the resampling ratio
Then you can compare the two data vectors.
source to share
There are two ways I can think of:
1- Matching size:
- Generating more data for a matrix with fewer elements (using interpolation, etc.)
- Removing some data from a matrix with a large number of elements (i.e. removing the delete)
2- Comparison of matrices with their properties.
For example, you can calculate the mean and covariance of a matrix and compare it to another matrix. Other embodiments include cov
, mean
, median
, std
, var, xcorr
, xcov
.
source to share