I don't know how to make and algorithm to find BMI?
조회 수: 2 (최근 30일)
이전 댓글 표시
I don't know how to make a MATLAB program that calculates BMI?
댓글 수: 0
답변 (1개)
Vilém Frynta
2023년 2월 3일
This looks like homework.
Try creating a function. Inputs will be height and weight, and output will be the BMI.
Some useful links that might help you:
댓글 수: 10
DGM
2023년 2월 5일
편집: DGM
님. 2023년 2월 5일
If you're putting the function into a script, then you won't be able to call from the command line. It's local to the script, so you call it within the script.
% this is a script
% call the local function
result = myfunction(5)
% this is a local function within a script
function out = myfunction(in)
out = in*10;
end
Otherwise, you can create a function file and place it somewhere on the path. Then you can call it where ever you want. See Star Strider's link.
Note that while you can turn any script into a function, function files contain only functions, and are treated differently than script files. Unless you've structured the file as a function, you'll have issues trying to execute it as a function.
참고 항목
카테고리
Help Center 및 File Exchange에서 File Name Construction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!