Creating a matrix by some other matrices

5 ビュー (過去 30 日間)
Moe
Moe 2014 年 5 月 12 日
コメント済み: Moe 2014 年 5 月 12 日
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 日
Try this:
c = [a, b*ones(size(a))]
  1 件のコメント
Moe
Moe 2014 年 5 月 12 日
Thanks.

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

その他の回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2014 年 5 月 12 日
c = a;
c(:,2)=b;
  1 件のコメント
Moe
Moe 2014 年 5 月 12 日
Thanks.

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


Azzi Abdelmalek
Azzi Abdelmalek 2014 年 5 月 12 日
編集済み: Azzi Abdelmalek 2014 年 5 月 12 日
[a 2*ones(size(a))]
  1 件のコメント
Moe
Moe 2014 年 5 月 12 日
Thanks.

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

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by