Matrix Averaging
조회 수: 6 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matt Fig
2011년 4월 13일
If A is your matrix and tol stands for "a certain average,"
if mean(A(:,1))<tol
M = mean(A(:,2:5));
end
댓글 수: 0
추가 답변 (1개)
Sean de Wolski
2011년 4월 13일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!