Filter before dividing

A contact-pressure calculation uses paired force readings F = [0 12 18 20] in newtons and contact areas A = [0 3 0 5] in square metres. Zero areas are invalid readings. For positive areas, pressure is pi=Fi/Aip_i=F_i/A_i.


The output must retain all four sample positions, contain zero at invalid positions, and avoid evaluating any division by zero. Given good = A > 0;, which code meets all three requirements?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Vectorized Code and Logical Operations Questions: