Matrix Averaging
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm trying to do something very simple, but can't seem to get the if condition correct.
I want to find the average of (:,2:5) if the values in the first column of the matrix are below a certain average.
Thanks in advance,
Ready to be humbled---
0 Kommentare
Akzeptierte Antwort
Matt Fig
am 13 Apr. 2011
If A is your matrix and tol stands for "a certain average,"
if mean(A(:,1))<tol
M = mean(A(:,2:5));
end
0 Kommentare
Weitere Antworten (1)
Sean de Wolski
am 13 Apr. 2011
A = rand(5);
A1 = A(:,1);
A1(A1>.5) = mean(A(A1>.5,2:5),2)
Like this? If not, please provide a small example.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical 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!