フィルターのクリア

function with two inputs.

3 ビュー (過去 30 日間)
Amireza Hassannejad
Amireza Hassannejad 2020 年 12 月 17 日
回答済み: Doddy Kastanya 2020 年 12 月 17 日
hey there. i wanted to write a little code to convert cm and kg to in and lb. i wrote this code but it doesnt work. can u help me?
this is my function:
function [height_in,weight_lb]=SI2US(height_cm,weight_kg)
height_in=height_cm/2.54;
weight_lb=weight_kg/0.4536;
end
and this is my code for using that fun:
height_cm=input('enter your height in cm: ');
weight_kg=input('enter your weight in kg: ');
SI2US(height_cm, weight_kg)

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 12 月 17 日
編集済み: Fangjun Jiang 2020 年 12 月 17 日
Run this to return two outputs
height_cm=input('enter your height in cm: ');
weight_kg=input('enter your weight in kg: ')
[height_in,weight_lb]=SI2US(height_cm,weight_kg)

その他の回答 (1 件)

Doddy Kastanya
Doddy Kastanya 2020 年 12 月 17 日
The code you have now already has the information you needed. However, you have not printed out the results yet.
You need to modify the calling to SI2US to assigned the converted quantities into respective variables. For example, it can be changed to [height,weight]=SI2US(heigh_cm,weight_kg). Please keep in mind that "height" and "weight" when calling the function could be any name you desire.
I hope this helps.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by