Bring two vectors in the same length
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi MATLAB Experts,
I have the following problem:
I have two data vectors v1 (Length N1=13812) and v2 (Length N2=60002021). I have to bring both vectors in the same length N3 using interpolation bzw. downsampling, with the requirement: 2xN1<N3<N2.
Can somebody help me? My idea was to use: interp, interp1 and downsample to solve to problem. Is that the right approach?
답변 (1개)
Michael Abboud
2016년 9월 28일
Once you pick a value for N3 within your requirements, you can try something such as the following command, which should work for both interpolating to a larger or smaller length.
>> x1 = 1:N1;
>> v1_N3 = interp1( x1*N3/N2, v1, 1:N3);
The idea is that your original signal “v1” has an implicit corresponding vector “x1” such that each data point lies at (x,y) = (x1,v1). You want to scale your existing vector “x1” such that the values of “v1” lie within [1, N3], but not necessarily on integer values. E.g. your first 3 values of “v1” might land on x = [1, 1.7, 2.4, …]. Then you request values of “v1_N3” at the exact indices of xq = 1:N3.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!