Creating a matrix by some other matrices

Suppos I have:
a = [3;3;5;8;2;1;8;1;5];
b = 2
I want matrix c to be:
c = [3 2;3 2;5 2;8 2;2 2;1 2;8 2;1 2;5 2]
second column of matrix c is just repeated b

 採用された回答

Image Analyst
Image Analyst 2014 年 5 月 12 日

0 投票

Try this:
c = [a, b*ones(size(a))]

その他の回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2014 年 5 月 12 日

1 投票

c = a;
c(:,2)=b;
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 12 日
編集済み: Azzi Abdelmalek 2014 年 5 月 12 日

0 投票

[a 2*ones(size(a))]

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

質問済み:

Moe
2014 年 5 月 12 日

コメント済み:

Moe
2014 年 5 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by