MATLAB Answers

How to match the origins of two different length vectors and pad zeros to match their length?

2 views (last 30 days)
Warren Cheng
Warren Cheng on 14 Sep 2021
Commented: Warren Cheng on 14 Sep 2021
Hello,
I am tasked to create a function that adds two different signals for digital signal processing. I am aware that the signals should have the same length in order to get the right sum between them. My problem is how would I go about aligning their origins and adding the zeros necessary in order to ensure correct addition between the 2 signals.
Any help would be greatly appreciated.

Answers (1)

KSSV
KSSV on 14 Sep 2021
You must be having (t1,x1) and (t2,x2) ; these are two singlas.
You can pick the superset time out of (t1,t2). For the other findout where the time matches with other, get index and fill zeros.
Also you can pick the suprset, use interp1 for the other signals with extrapolation off.

Community Treasure Hunt

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

Start Hunting!