How do I compare two similar sized matrices?

4 次查看(过去 30 天)
Hi all!
I have two 76x2000 matrices and I would like to compare them to see which one is always higher. What is the best way for me to go about this? A function that would allow me to put in different pairs would be most appreciated.
Thank you!
  6 个评论
per isakson
per isakson 2016-8-22
编辑:per isakson 2016-8-22
"what do you mean by a 76x2000 logical array" &nbsp there is a good answer in the middle of Introducing MATLAB Fundamental Classes (Data Types)
I still don't fully understand what you mean by "matrices have a higher value". The example you provided above explains "higher" regarding scalars, not matrices. Please give a small example regarding matrices. See Norm (mathematics) and Vector and matrix norms.
Lakyn
Lakyn 2016-8-22
Thanks for the link! explains a lot.
Well, I think it can be said to mean that every single value in that matrix is higher than the corresponding one in the other matrix. So for example, 3rd row 80th column value of the first matrix is higher than the 3rd row 80th column value of the second matrix.

请先登录,再进行评论。

采纳的回答

per isakson
per isakson 2016-8-22
编辑:per isakson 2016-8-22
"every single value in that matrix [ A ] is higher than the corresponding one in the other matrix [ B ]"
is_gt = A > B;
is_higher = all( is_gt(:) );
(:) is a trick to reshape a matrix to a column vector.
  6 个评论
Lakyn
Lakyn 2016-8-22
interesting, thanks for that.
What if say, I want to compare just the 76 rows? Is there a way for me to average the 2000 columns to get a single value for each row, and then compare the two matrices?
Thank you so much! Sorry I keep asking questions haha
per isakson
per isakson 2016-8-22
First, watch the video Working with Arrays in MATLAB carefully.
Secondly, try
is_gt = mean(A,1,'omitnan') > mean(B,1,'omitnan');
is_higher = all( is_gt(:) );

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by