how to substitute a row vector to a column of a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Grace
am 12 Jun. 2014
Kommentiert: Samuel Akpobome
am 25 Jan. 2018
Hi, I have
a=[1 2 3 4;
5 6 7 8;
9 10 3 4]
b=[4 5 7]
I want to substitute b to my second column of a to become
c=[1 4 3 4;
5 5 7 8;
9 7 3 4]
what can I do?
Thanks.
0 Kommentare
Akzeptierte Antwort
Jos (10584)
am 12 Jun. 2014
a = [1 2 3 4;
5 6 7 8;
9 10 3 4]
b = [4 5 7]
c = a % copy a
c(:,2) = b(:) % transform b into a column vector and replace the 2nd column of c with it
2 Kommentare
Samuel Akpobome
am 25 Jan. 2018
You can do this as follows;
c(:,2:3)=[b(:) b(:)] %this substitutes b(as a column matrix) into columns 2 and 3 (or 2 to 3) in the matrix c
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu NaNs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!