Question

Write a Matlab function convert T such that convert T(x, ’C’) converts from degrees Celsius to...

Write a Matlab function convert T such that convert T(x, ’C’) converts from degrees Celsius to degrees Fahrenheit, while convert T(x, ’F’) converts from Fahrenheit to Celsius.

Need to submit program online to see if successful. Please help!

function T = convert_T (x, flag)

%convert between Celsius and Fahrenheit temperatures
%for example, convert_T(10, 'C') should return 50
%and convert_T(50, 'F') should return 10

Homework Answers

Answer #1

Input Code:

function T = convert_T(x,flag)
if (flag == 'F' || flag == 'f')
converted = (x-32)*(5/9);

convertedto = 'C';
T =converted;
  
elseif (flag == 'C' || flag == 'c')
converted = x*(9/5) + 32;
convertedto = 'F';
T =converted;
  
else
fprintf('\nYou have given a wrong input\n')

end

==================================================

Note:you go to the command prompt and type “convert_T(inputvalue1, inputvalue2)”. This means you type your function's name and the values you want to assign to the inputs.Then you will get result


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Program must be in JAVA. Write a program that converts temperature from Celsius to Fahrenheit or...
Program must be in JAVA. Write a program that converts temperature from Celsius to Fahrenheit or vice versa, depending on user's input. The formula for converting temperature in Celsius to Fahrenheit is, Fahrenheit = (9/5) * Celsius + 32 The formula for converting temperature in Fahrenheit to Celsius is, Celsius = (5/9) * (Fahrenheit – 32) Results should be rounded to two decimal points, e.g., 92.56
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale...
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale conversion he/she would like to perform: 1. Convert F to C 2. Convert C to F 3. Quit What is your choice? Then it asks the user for input for three real number variables: start_temp, end_temp, temp_incr. It will then produce a two column Fahrenheit to Celsius table or a two column Celsius to Fahrenheit table, depending on the choice. For choice 1, the...
Write a program in java that generates a two-column table showing Fahrenheit temperatures from -40F to...
Write a program in java that generates a two-column table showing Fahrenheit temperatures from -40F to 120F and their equivalent Celsius temperatures. Each line in the table should be 5 degrees F more than the previous one. Both the Fahrenheit and Celsius temperatures should be accurate to 1 decimal place. I am not able to use: import java.text.DecimalFormat; Any feedback would be helpful.
The change in temperature in Kelvin and Celsius is the same, as it should be. QUESTION...
The change in temperature in Kelvin and Celsius is the same, as it should be. QUESTION Which represents the larger temperature change, a Celsius degree or a Fahrenheit degree? It's subjective and depends on the observer's judgment.One degree is the same on either scale.    It depends on the initial temperature.FahrenheitCelsius PRACTICE IT Use the worked example above to help you solve this problem. The temperature gradient between the skin and the air is regulated by cutaneous (skin) blood flow. If the...
Write a program that accepts an input string from the user and converts it into an...
Write a program that accepts an input string from the user and converts it into an array of words using an array of pointers. Each pointer in the array should point to the location of the first letter of each word. Implement this conversion in a function str_to_word which returns an integer reflecting the number of words in the original string. To help isolate each word in the sentence, convert the spaces to NULL characters. You can assume the input...
The temperature in degrees Celsius on the surface of a metal plate is T (x, y)...
The temperature in degrees Celsius on the surface of a metal plate is T (x, y) = 20 − 4x^(2) − y^(2) where x and y are measued in centimeters. In which direction from the point (2, −3) does the temperature increase most rapidly? What is this rate of increase in that direction? c.∗ How much greater is the rate of increase from (2, −3) in the direction of the gradient, then the rate of change in the direction of...
Using Python, write the following code. You are to allow the user to enter the daily...
Using Python, write the following code. You are to allow the user to enter the daily temperature as a floating-point number. You should make the assumption that you are recording temperatures in Fahrenheit. You should allow the user to continue entering temperatures until the value -999 is entered. This number should not be considered a temperature, but just a flag to stop the program. As the user enters a temperature, you should display the following each time: Current Temperature: 999...
MATLAB 2017b Write a program which will: Accept three numbers from the user: a, b and...
MATLAB 2017b Write a program which will: Accept three numbers from the user: a, b and c which can assume any value. Accept Dx and Dy for the calculations of the function Write a function which accept a, b, c, Dx and Dy and will draw the following surface Where x and y vary in the range of -10?x?10 -10?y?10. Allow the user to rerun the program and exit the program upon request.
Write a C++ program that converts time of day from a 24-hour notation to a 12-hour...
Write a C++ program that converts time of day from a 24-hour notation to a 12-hour notation. For example, it should convert 14:25 to 2:25 PM. (A) The user provides input as two integers separated by ‘:’. The following function prototype should capture the user inputs as described below: void input(int& hours24, int& minutes); //Precondition: input(hours, minutes) is called with //arguments capable of being assigned values. //Postcondition: // user is prompted for time in 24 hour format: // HH:MM, where...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that implements the bisection method. You function should take as input 4 arguments with the last argument being optional, i.e, if the user does not provide the accuracy tol use a default of 1.0e-6 (use varargin to attain this). Your function should output the approximate root, approx_root and the number of iterations it took to attain the root, num_its. However, if the user calls the...