How do I make an average of points ?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ernest Adisi
am 22 Aug. 2018
Bearbeitet: jonas
am 22 Aug. 2018
Hi, say I have an 11*10 matrix and for every point in the 6th row, I want matlab to take an average of the surrounding points and make a new row; ie 1 point has 8 surrounding points then the same for each point in the row, how would this be done please ? Thanks
2 Kommentare
Akzeptierte Antwort
jonas
am 22 Aug. 2018
Bearbeitet: jonas
am 22 Aug. 2018
Based on your simple example:
A=[1 2 3 4 5 6 7 8 9 10;
5 2 4 6 7 4 5 6 7 8;
1 2 3 4 5 6 7 8 9 10]
out = conv2(A,ones(3,3)./9,'same')
This will give you the average of all 9 neighboring values. Second row:
out(2,:)
ans =
Columns 1 through 10
1.4444 2.5556 3.3333 4.5556 5.2222 5.7778 6.3333 7.3333 8.3333 5.8889
0 Kommentare
Weitere Antworten (1)
Yuvaraj Venkataswamy
am 22 Aug. 2018
Bearbeitet: Yuvaraj Venkataswamy
am 22 Aug. 2018
Check this,
if true
X = rand(11,10);
k = 6;
MA = movmean(X,[(k-1) 0]);
Y = MA(k:k:end,:);
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating 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!