need help on user-defined MATLAB function
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
What can i alter in my function file so this "ans " will not be displayed in the command window. Or how can i remove it?
My function file contains:
function [ height_cm, mass_kg ] = height_weight_conversion(height_ft, height_in, mass_lb)
% Determining the height in centimeters (cm) and mass in kilograms (kg)
% of a person from his height in inches (in.) and weight in pounds (lb).
% Inputs:
% height_ft = height in feet
% height_in = height in inches
% mass_lb = weight in pounds
% Outputs:
% height_cm = height in centimeters
% mass_lb = weight in kilograms
height_ft = input('Enter height in feet(ft):');
height_in = input('Enter height in inches(in):');
mass_lb = input('Enter mass in pounds(lb):');
% Converting height in feet to inches
ft_to_in = height_ft * 12;
% Calculating the height in inches to centimeters
height_cm = (ft_to_in + height_in) * 2.54;
% Calculating the weight in pounds to kilograms
mass_kg = mass_lb / 2.20462;
fprintf('The height is %.2f centimeters(cm) and weight is %.2f kilograms(kg)',height_cm,mass_kg)
end
Here's the pic of command window

0 Commenti
Risposte (1)
Walter Roberson
il 20 Apr 2021
function [ Height_cm, Mass_kg ] = height_weight_conversion(height_ft, height_in, mass_lb)
% Determining the height in centimeters (cm) and mass in kilograms (kg)
% of a person from his height in inches (in.) and weight in pounds (lb).
% Inputs:
% height_ft = height in feet
% height_in = height in inches
% mass_lb = weight in pounds
% Outputs:
% height_cm = height in centimeters
% mass_lb = weight in kilograms
height_ft = input('Enter height in feet(ft):');
height_in = input('Enter height in inches(in):');
mass_lb = input('Enter mass in pounds(lb):');
% Converting height in feet to inches
ft_to_in = height_ft * 12;
% Calculating the height in inches to centimeters
height_cm = (ft_to_in + height_in) * 2.54;
% Calculating the weight in pounds to kilograms
mass_kg = mass_lb / 2.20462;
fprintf('The height is %.2f centimeters(cm) and weight is %.2f kilograms(kg)',height_cm,mass_kg)
if nargout > 0
Height_cm = height_cm;
Mass_kg = mass_kg;
end
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!