Question about Test for equality

조회 수: 1 (최근 30일)
Lucas Neves
Lucas Neves 2016년 12월 17일
댓글: Star Strider 2016년 12월 17일
Hello guys!! So, i have this problem. I have two matrix of 125x3, with 1 and -1. When i do (A-B) then i will have one matrix of 125x3 full of zeros I need to know how many lines i have [0 0 0], so i need to count those lines and i will have a number ( obviously). I know how to use the length to get my number, but i'm having trouble testing the (A-B) matrix to find the lines with [0 0 0] Anyone has an advice for that?
Thanks a lot guys!!

채택된 답변

Star Strider
Star Strider 2016년 12월 17일
Try this:
A = [1 -1 1; 1 1 1; 0 1 0; 0 0 0; 1 0 -1; 0 0 0]; % Create Data
[Au,ia,ic] = unique(A, 'rows');
TallyRows = accumarray(ic, 1);
NumberOfZeroRows = TallyRows(1)
NumberOfZeroRows =
2
  댓글 수: 2
Lucas Neves
Lucas Neves 2016년 12월 17일
Thanks!! It helped me alot!!
Star Strider
Star Strider 2016년 12월 17일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Testing Frameworks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by