필터 지우기
필터 지우기

recreate vector

조회 수: 1 (최근 30일)
Sam
Sam 2012년 6월 18일
I have a compressed vector like this: a_compressed = [9 3 5] a_ending_indx = [4 6 9]
Without using FOR loop, what is the efficient way to uncompress that vector so that the full vector is a = [9 9 9 9 3 3 5 5 5]
Thanks, Sam

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 6월 18일
One of many ways:
a_c = [9 3 5];
a_x = [4 6 9];
B = zeros(1,a_x(end));
B([1 a_x(1:end-1)+1]) = 1;
C = a_c(cumsum(B))
  댓글 수: 1
Sam
Sam 2012년 6월 18일
Thanks Sean
Very helpful,
-Sam

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by