0

I have a matrix V. I want to test if the matrix equal to one or not.

Sometimes the sum(V(:))==1.0000 but when I test if sum(V(:))== 1 the results always FALSE.

How to solve that problem.

stevGates
  • 910
  • 2
  • 9
  • 19
  • 3
    Check their difference and make a tolerance for you to accept them being equal – Ander Biguri Dec 30 '22 at 12:08
  • do you mean (all the elements of) V==1 or sum(V)==1, show V otherwise readers assume it's a floating precision related problem and you have been referred to another QA. If you start with a closed set like for instance N=10;d=randi([100 999],1,N); V=d./d then you shouldn't have any problem with sum(V(:))==1 check – John BG Jan 01 '23 at 15:25

0 Answers0