Excuse me everyone, I want ask that how to repeating the matrix element like this example :
Example: y = [1; 2; 3; 4] and then I want the output like this (for example until N=7) :
Thanks

2 件のコメント

Matt J
Matt J 2018 年 9 月 23 日
編集済み: Matt J 2018 年 9 月 23 日
Why is there a '5' in x but not in y?
Dirga Eka Putra L
Dirga Eka Putra L 2018 年 9 月 23 日
編集済み: Dirga Eka Putra L 2018 年 9 月 23 日
Sorry Sir, I have a typo, I Fixed (for Example N=7) :
Thanks

サインインしてコメントする。

 採用された回答

Matt J
Matt J 2018 年 9 月 23 日

1 投票

m=numel(y);
y(mod(0:N-1,m)+1)

1 件のコメント

Dirga Eka Putra L
Dirga Eka Putra L 2018 年 9 月 23 日
It works, Thank you very much

サインインしてコメントする。

その他の回答 (1 件)

dpb
dpb 2018 年 9 月 23 日

2 投票

Just one of many possible ways...
L=length(y);
N=7;
x=repmat(y,ceil(N/L),1);
x=x(1:N);

1 件のコメント

Dirga Eka Putra L
Dirga Eka Putra L 2018 年 9 月 23 日
It works, Thank you very much

サインインしてコメントする。

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by