フィルターのクリア

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by