How to take mean of the first numbers of column in matrix and add to each number in same column?
Ältere Kommentare anzeigen
Hi guys I have a matrix:
A = [...
64 2 3 61 60 6 7 57
9 55 54 12 13 51 50 16
17 47 46 20 21 43 42 24
40 26 27 37 36 30 31 33
32 34 35 29 28 38 39 25
41 23 22 44 45 19 18 48
49 15 14 52 53 11 10 56
8 58 59 5 4 62 63 1]
Now I would like to take the mean of the first 4 numbers in column 1 and add to each number in column 1. In the second column I want to take the mean of the first 4 numbers and add to each number in column 2. And so on. Can this be done in a easy manner or do I have to import the data and calculate the mean myself and then add to the columns in the matrix? Help is greatly appreciated. Thx in advance.
Kind regards
A MatLab Novice
1 Kommentar
Image Analyst
am 5 Dez. 2014
Looks like homework - is it?
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 5 Dez. 2014
Bearbeitet: Azzi Abdelmalek
am 5 Dez. 2014
Edit
b=bsxfun(@plus,A,mean(A(1:4,:))')
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!