How can I subtract 2 2D graphs made by vectors of different length?

조회 수: 13 (최근 30일)
I have 2 sets of data from the same experiment recorded with different methods. The results are 2 graphs describing the same but with some differences. To find those differences I want to subtract the graphs so that I can have a visual representation of where the differences are located.
The problem I have is that the first method has a "X resolution" of 10 data points per second, but the second method's resolution is not constant, sometimes its 7, sometimes its 15. Because of this I can’t just subtract the arrays, since they are not the same length.
Is there a way to do this?

채택된 답변

Image Analyst
Image Analyst 2018년 6월 6일
Yes, just use interp1() to interpolate them to a common time sequence. If you can't figure it out, attach your two vectors in a .mat file, say what you want the new sampling spacing to be, and someone will do it for you.
  댓글 수: 1
Ricardo Fuertes
Ricardo Fuertes 2018년 6월 6일
Thanks! Its works. I had to remove some data points with the same X value, otherwise I would get 'The grid vectors must contain unique points.' error.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Alfonso
Alfonso 2018년 6월 6일
If you want to quantify the "difference" between 2 datasets of different length, say dataset A with length 100 and dataset B with length 150, you can interpolate the x and y coordinates of dataset A using the "interp1" function to 150 points (length B), then you could for example, calculate the RMSE between the 2 datasets to quantify the differences. (This is one of the ways you could do it)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by