Filling one vector with elements of another

3 ビュー (過去 30 日間)
Rory
Rory 2013 年 8 月 16 日
Hi,
My problem is I have two vectors,
one called 'Ua' of size (253,1)
and the other is called just 'vector' and is currently filled with zeros and is of size (4048,1).
What I want to do is fill rows 1:16 of 'vector' with Ua(1,1), fill rows 17:32 of 'vector' with Ua(2,1) etc. all the way up to filling rows 4032:4048 of vector with Ua(253,1).
What Ive tried to do, and does not work, is a really simple for loop as follows:
for i=1:253 vector(1:1:16:4048,1)=Ua(i,1); end
Obvioulsy this does not work and I'm struggling to figure out how to do this quite simple problem.
Can anyone offer any solutions?
Thanks
R

採用された回答

Jan
Jan 2013 年 8 月 16 日
編集済み: Jan 2013 年 8 月 16 日
vector = repmat(Ua', [16, 1]);
vector = vector(:);
  1 件のコメント
Rory
Rory 2013 年 8 月 16 日
Thankyou for quick reply. I thought there would be an easy solution.....

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by