How to compare two vectors that don't have equal length?

조회 수: 7 (최근 30일)
Malahat Mehraban
Malahat Mehraban 2021년 12월 9일
댓글: Voss 2021년 12월 14일
Hello everyone,
I have two vectors, x1 with a length of 755, and x2 a the length of 756.
I want to minus these two vectors to find out how much their cells are different.
do you have any suggestions to make these comparison?
for example: x1=[21, 108, 195, 281,..... ] (length=755) and x2=[21, 109, 197, 280, ......] (length=756)
I appreciate any suggestions...

채택된 답변

Voss
Voss 2021년 12월 9일
Well, you can compare the first 755 elements:
dx = x1 - x2(1:end-1);
or you could compare the last 755 elements:
dx = x1 - x2(2:end);
Based on the first few elements that you mentioned, probably the first option is what you want. No matter what, you're going to have one element of x2 that's left out.
  댓글 수: 6
Malahat Mehraban
Malahat Mehraban 2021년 12월 13일
Thank you Benjamin, it works great.
What is your opinion about using the time of peak occurred instead of using an index? actually, I want to use a 128-millisecond tolerance for the comparison. If the detected peak is 128 milliseconds sooner or later than the detected peak of the other method, it will determine as a wrong detection.
Voss
Voss 2021년 12월 14일
Assuming those data are regularly-sampled, it shouldn't matter whether you use index or time.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by