Matlab is not recognizing that two floats are equal although Workspace shows they are
조회 수: 3(최근 30일)
line_lengths = calculate_line_lengths(plane_x,plane_y, rect_corners);
% send the above two answers to herons_formula, get 4 areas
four_areas = herons_formula(edge_lengths, line_lengths);
sum_four_areas = sum(four_areas);
if sum_four_areas == rect_area
in_rect = true;
elseif sum_four_areas < rect_area
in_rect = false;
My code falls into the elseif when it should be going into the if statement as they are equal.
Prateek Rai 2022년 2월 24일
You can refer to following MATLAB Answers on Why two equal numbers are not equal? to get more idea on why MATLAB is not recognizing that two floats are equal although workspace shows that they are equal.