Matlab计算BMI数值与健康指标的函数 您所在的位置:网站首页 怎么算bmi怎么算 Matlab计算BMI数值与健康指标的函数

Matlab计算BMI数值与健康指标的函数

2024-06-15 03:32| 来源: 网络整理| 查看: 265

Homework problem: Write a Matlab function to calculate the body mass index (BMI) with the following function prototype:

function [BMI, status] = ComputeBMI(weight_kg, height_cm)

where the input weight_kg is the weight measured in kilograms and height_cm is the height measured in centimeters. The output BMI is the calculated BMI according to the inputs, and status should be 1, 2, 3, or 4 indicating the status of “underweight”, “normal or healthy weight”, “overweight”, or “obese”. Notice that the output BMI should be rounded to have precision to 0.1 and the status is determined according to BMI with this precision. For example, for a guy with weight of 68 kg and height of 165 cm, the output BMI should be 25.0 and the status should be 3 indicating “overweight”. Please refer to the webpage below for more info on BMI:

有关BMI计算公式与指标的资料

function [BMI, status] = ComputeBMI(weight_kg, height_cm) %本代码可以实现输入身高体重后计算人体BMI(精确度为小数点后1位)数值 %并根据BMI数值的范围告知测试者身体状况 height_m = height_cm / 100; %计算BMI数值,并进行四舍五入的保留一位小数 BMI = weight_kg / (height_m)^2; BMI = roundn(BMI,-1); %根据不同的BMI数值,规定status的数值 if BMI < 18.5 status = 1; elseif BMI


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有