免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
返回列表 发帖

关于Matlab的疑问

这道题我提交的答案是
  1. function bmi = bmi_calculator(hw)
  2. % Convert the height values from inches to meters
  3. h=hw(:,1)*0.0254;
  4. % Convert the weight values from lbs to kilograms
  5. w=hw(:,2)/2.2;
  6. bmi=zeros([1 size(hw,1)]);
  7. for i=1:size(hw,1)
  8.   bmi(i) = w(i)/h(i)^2;
  9. end
  10. end
复制代码
它通过了Test 2,但是Test 1报错,如下

Error using assert The condition input argument must be convertible to a scalar logical. Error in Test1 (line 4) assert(all(abs(bmi_calculator(hw) - bmi_correct) < 1e-4))

这是为什么呢

返回列表 回复 发帖