필터 지우기
필터 지우기

comparison of vectors and reducing size

조회 수: 2 (최근 30일)
Tahir Afareen
Tahir Afareen 2019년 10월 6일
댓글: Tahir Afareen 2019년 10월 6일
Greetings,
I have three vectors A , B and C of sizes 299×1 , 499×1 and 1609×1 respectively. i need code to simply reduce the size of the two large vectors (in this case B and C) to the size of the smallest vector (in this case A). how do i do that?

채택된 답변

meghannmarie
meghannmarie 2019년 10월 6일
If you want to just keep the first 299 elements:
sz = min([length(A),length(B),length(C)]);
A = A(1:sz);
B = B(1:sz);
C = C(1:sz);
  댓글 수: 1
Tahir Afareen
Tahir Afareen 2019년 10월 6일
Thank you very much meghannmarie.
problem solved.

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

추가 답변 (1개)

Ajay Kumar
Ajay Kumar 2019년 10월 6일
doc interp1
use linear interpolation, to upsample or downsample the vector to any length required
A = rand(299,1);
B = rand(499,1);
v = (1:numel(B))';
vr = (linspace(min(v), max(v), length(A)))';
newB = interp1(v, B, vr);
Hope this helps :)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by