Matrix Averaging
2 次查看(过去 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!