Creating a matrix by some other matrices

2 visualizzazioni (ultimi 30 giorni)
Moe
Moe il 12 Mag 2014
Commentato: Moe il 12 Mag 2014
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

Risposta accettata

Image Analyst
Image Analyst il 12 Mag 2014
Try this:
c = [a, b*ones(size(a))]

Più risposte (2)

Andrei Bobrov
Andrei Bobrov il 12 Mag 2014
c = a;
c(:,2)=b;

Azzi Abdelmalek
Azzi Abdelmalek il 12 Mag 2014
Modificato: Azzi Abdelmalek il 12 Mag 2014
[a 2*ones(size(a))]

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by