Creating a matrix by some other matrices

2 次查看(过去 30 天)
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))]

更多回答(2 个)

Andrei Bobrov
Andrei Bobrov 2014-5-12
c = a;
c(:,2)=b;

Azzi Abdelmalek
Azzi Abdelmalek 2014-5-12
编辑:Azzi Abdelmalek 2014-5-12
[a 2*ones(size(a))]

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by