找回密码
 快速注册
搜索
查看: 225|回复: 0

关于Matlab的疑问

[复制链接]

3147

主题

8384

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65372
QQ

显示全部楼层

hbghlyj 发表于 2021-11-16 08:59 |阅读模式
这道题我提交的答案是
  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))

这是为什么呢

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 19:07

Powered by Discuz!

× 快速回复 返回顶部 返回列表