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 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...
java script Define a function named height which has two inputs. This first input is the...
java script Define a function named height which has two inputs. This first input is the number of feet. The second input is the number of inches. Both inputs will be Number values. Your function must calculate and return a Number. he returned value represents number of meters equal to the input. Your function should start by multiplying the first parameter by 0.3048 (1 foot is 0.3048 meters). Then multiply the second input by 0.0254 (1 inch is 0.0254 meters)....
Question 1: 5pts Write a program to receive two integers as user input and then print:...
Question 1: 5pts Write a program to receive two integers as user input and then print: Sum Difference Product Average Maximum of the two Minimum of the two You may use the min and max functions declared in the math class. ********************************************************************************** Question 2: 10pts An online bank wants you to create a program that will show a prospective customer, how the deposit will grow. Your program should read the initial balance and the annual interest rate. Interest rate is...
Question 1: Write a program to receive two integers as user input and then print: Sum...
Question 1: Write a program to receive two integers as user input and then print: Sum Difference Product Average Maximum of the two Minimum of the two You may use the min and max functions declared in the math class. ********************************************************************************** Question 2: An online bank wants you to create a program that will show a prospective customer, how the deposit will grow. Your program should read the initial balance and the annual interest rate. Interest rate is compounded monthly....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT