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
Write a function called celsiusToFaherenheit which takes 1 input: degrees in Celsius, and returns one output:...
Write a function called celsiusToFaherenheit which takes 1 input: degrees in Celsius, and returns one output: degrees in Fahrenheit. The formula to convert Celsius to Fahrenheit is (°C × 9/5) + 32 = °F. Write a function called printCelsiusToFaherenheit which takes no inputs and returns no outputs. This function should use celsiusToFaherenheit from part 3 as a helper function. This function should print the value of 17 degrees Celsius converted to Fahrenheit.
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.
Use Python: the formula for converting a temperature from Fahrenheit to Celcius is C=5/9(f-32) where F...
Use Python: the formula for converting a temperature from Fahrenheit to Celcius is C=5/9(f-32) where F is the Fahrenheit temperatre and C is the celcius temperature. Write a function named celcius that accepts a Fahrenheit temperature as an argument. the function should return the temperature, convertedm to celcius. Demonstrate the function by calling it in a loop that displays a table of the fahrenheit temperatures 0 through 20 and their Celsius equivalents.
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...
// This program prints a table to convert numbers from one unit to another. // The...
// This program prints a table to convert numbers from one unit to another. // The program illustrates some implementation techniques. //Include the header file ostream for including all stream. ---------------------------------------------------------*/ #include <iostream> //Provides cout <v1.0> //Include iomanip that is used for set precision. #include <iomanip> //Provides setw function for setting output width <v1.1> //Header file for EXIT_SUCCESS. #include <stdlib.h>// Provides EXIT_SUCCESS <v1.2> //Header file for assert. #include <assert.h>// Provides assert function <1.3> using namespace std; // Allows all standard...
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...
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...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT