How can I combine two columns?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi I have a two column matrix. How can I merge and average them?
For example, if the matrix was
5 9
3 1
1 7
Then the output would be
7
2
4
0 Kommentare
Antworten (3)
David Sanchez
am 21 Jun. 2013
Use the built-ibn function cat:
a = [1 2; 3 4];
b1 = [2 4];
b2 = [2; 4];
c1 = cat(1,a,b1);
c2 = cat(2,a,b2);
>> c1
c1 =
1 2
3 4
2 4
>> c2
c2 =
1 2 2
3 4 4
read
help cat
for more options.
0 Kommentare
Chetan Aswathanarayana
am 21 Jun. 2013
Bearbeitet: Chetan Aswathanarayana
am 21 Jun. 2013
If A = [5 9
3 1
1 7]
>> B = A';
>> B = mean(B);
>> B = B'
B =
7
2
4
0 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!