Question

In: Advanced Math

Write a function that will receive two input arguments that is the height in inches (in.)...

  1. Write a function that will receive two input arguments that is the height in inches (in.) and the weight in pounds (lb) of a person and return two output arguments that is the height in meters (m) and mass in kilograms (kg).

  1. Determine in SI units the height and mass of a 5 ft.15 in. person who weight 180 lb.
  2. Determine your own height and weight in SI units.

Note: 1 meter = 39.3701 inch, 1 foot = 12 inches, 1 pound = 0.453592 kilogram

Solve this please using MATLAP

Solutions

Expert Solution

Answer:) The code for this function is as follows:

CODE:

%%% Function definition
function [ height_m, weight_kg ] = converter( height_in, weight_lb )
% This function takes the height in inches and weight in pounds as
% inputs, and outputs the height in meters and weight in kilograms

   feet = floor(height_in); % get the number of whole feet
   inches = 100*(height_in - feet); % get the number of inches
   height_m = (feet * 12 + inches) / (39.3701); % convert feet to inches,
                                                % and then convert inches
                                                % to m
   weight_kg = 0.453592 * weight_lb; % use the conversion from pounds to kg
   disp("Weight in kg : ")
   disp(weight_kg)
   disp("Height in m : ")
   disp(height_m)
   return
end


The code looks as follows when typed out in MATLAB:

Suppose we give the input height = 5 ft 15 inches, weight = 180 lb (given as an input which looks like (5.15, 180) ), we get :

>>converter(5.15, 180)
Weight in kg :
81.646559999999994
Height in m :
   1.904998971300556

OUTPUT:

Note: the final 'ans' is just the function returning the first variable's value, and is the same as the height_m variable's value.

Suppose the user's weight is 170 lb, and the user's height is 6 ft 10 inches. This would be :

>> converter(6.10, 170)
Weight in kg :
77.110640000000004
Height in m :
   2.082798875288606


Related Solutions

Write a user-defined MATLAB function, with two input and two output arguments that determines the height...
Write a user-defined MATLAB function, with two input and two output arguments that determines the height in centimeters (cm) and mass in kilograms (kg)of a person from his height in inches (in.) and weight in pounds (lb). (a) Determine in SI units the height and mass of a 5 ft.15 in. person who weight 180 lb. (b) Determine your own height and weight in SI units.
Write a function called alternate that takes two positive integers, n and m, as input arguments...
Write a function called alternate that takes two positive integers, n and m, as input arguments (the function does not have to check the format of the input) and returns one matrix as an output argument. Each element of the n-by-m output matrix for which the sum of its indices is even is 1. All other elements are zero. For example, here is an example run: >> alternate(4,5) ans = 1 0 1 0 1 0 1 0 1 0...
Write a Python program that takes as input two numbers, the height, and width of a...
Write a Python program that takes as input two numbers, the height, and width of a rectangle. It then prints a rectangle with height lines and width characters in each line. The rectangle should contain information regarding its dimensions and area inside (centered vertically but not horizontally). If any part of the information (including two stars on each end and a space before and after the line) does not fit in the rectangle, then print the complete information after the...
. Write   a   function   that   takes,   as   arguments,   two   objects,   value1   and   value2.       If  
. Write   a   function   that   takes,   as   arguments,   two   objects,   value1   and   value2.       If   value1   and   value2   are   either   integers   or   strings   containing   only   digits,   cast   value1   and   value2   to   integers   and   compute   their   average.       If   their   average   is   greater   than   50,   return   the   string   “Above   50”   and   if   the   average   is   less   than   50,   return   the   string   “Below   50”.       If   the   average   is   equal   to   50,   return   the   string   “Equal   to   50”,   and   if   value1   or  ...
Write a simple function template for predicate function isEqualTo that compares its two arguments of the...
Write a simple function template for predicate function isEqualTo that compares its two arguments of the same type with the equality operator (==) and returns true if they are equal and false if they are not equal. Use this function template in a program that calls isEqualTo on a variety of built-in types and user define types, Complex and Date (need to overload the equality operator (operator==) and extraction operator (operator<<)).  Write a program with variety of inputs to test the...
Write a simple function template for predicate function isEqualTo that compares its two arguments of the...
Write a simple function template for predicate function isEqualTo that compares its two arguments of the same type with the equality operator (==) and returns true if they are equal and false if they are not equal. Use this function template in a program that calls isEqualTo on a variety of built-in types and user define types, Complex and Date (need to overload the equality operator (operator==) and extraction operator (operator<<)).  Write a program with variety of inputs to test the...
Write a simple function template for predicate function isEqualTo that compares its two arguments of the...
Write a simple function template for predicate function isEqualTo that compares its two arguments of the same type with the equality operator (==) and returns true if they are equal and false if they are not equal. Use this function template in a program that calls isEqualTo on a variety of built-in types and user define types, Complex and Date (need to overload the equality operator (operator==) and extraction operator (operator<<)).  Write a program with variety of inputs to test the...
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
JavaScript Write a function called "first" that takes in two arguments - the first is an...
JavaScript Write a function called "first" that takes in two arguments - the first is an argument called arr that is an array of numbers, the second is an optional number argument called num(hint: you'll need a default value - look back at the slides). If "num" was not passed in (since it's optional), the "first" function will return an array containing the first item of the array. If a value for "num" was given, the "first" function will return...
(python) Write a function that involves two arguments, named changeTheCase(myFile, case),thattakes, as arguments, the name of...
(python) Write a function that involves two arguments, named changeTheCase(myFile, case),thattakes, as arguments, the name of a file, myFile, and the case, which will either be"upper"or"lower".If case is equal to "upper" the function will open the file, convert all characters on each line to upper case, write each line to a new file, named "upperCase.txt", and return the string "Converted file to upper case."If case is equal to "lower" the function will open the file, convert all characters on each...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT