I want to repeat every element of a column array (10rows,1column) four times, and put all together in one column array.. please suggest any method

1 回表示 (過去 30 日間)
eg: t(10,1)=[1;2;3;4;5;6;7;8;9;10] and i want result=[1;1;1;1;2;2;2;2;3;3;3;3;4;4;4;4;5;5;5;5;6;6;6;6;7;7;7;7;8;8;8;8;9;9;9;9;10;10;10;10]
please any body suggest the way out thank you

回答 (4 件)

Alexandra Harkai
Alexandra Harkai 2016 年 12 月 2 日
repelem(t, 4)
  4 件のコメント
Mohammed Yousuf
Mohammed Yousuf 2016 年 12 月 2 日
my matlab version isR2009a may be that may be the reason
Guillaume
Guillaume 2016 年 12 月 3 日
repelem was introduced in R2015a. It is a good idea to mention which matlab version you're using in the question particularly when it's that out of date.

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


Andrei Bobrov
Andrei Bobrov 2016 年 12 月 2 日
編集済み: Andrei Bobrov 2016 年 12 月 2 日
result = kron(t,ones(4,1));

Jan
Jan 2016 年 12 月 2 日
t = [1;2;3;4;5;6;7;8;9;10];
r = repmat(t.', 4, 1);
r = r(:);

Mohammed Yousuf
Mohammed Yousuf 2016 年 12 月 3 日
thank you i got the answer
  1 件のコメント
Jan
Jan 2016 年 12 月 5 日
Then select the answer, which solves your problem or post an own answer for selecting, such that the forum can see, that the problem ist solved. Thanks.

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by