Forgot password?
 Create new account
View 280|Reply 0

关于Matlab的疑问

[Copy link]

3148

Threads

8494

Posts

610K

Credits

Credits
66173
QQ

Show all posts

hbghlyj Posted at 2021-11-16 08:59:09 |Read mode
这道题我提交的答案是
  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
Copy the Code
它通过了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))

这是为什么呢

手机版Mobile version|Leisure Math Forum

2025-4-21 01:08 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list