Forgot password
 Register account
View 357|Reply 0

关于Matlab的疑问

[Copy link]

3204

Threads

7842

Posts

48

Reputation

Show all posts

hbghlyj posted 2021-11-16 08:59 |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))

这是为什么呢

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-6 08:22 GMT+8

Powered by Discuz!

Processed in 0.013651 seconds, 22 queries