
Concept explainers
To write:
• A program to call a
• A program to call a function to prompt the user for the minimum and maximum temperatures in degrees Fahrenheit, and return both values.
• A program to call a function to write temperature to a file as the temperature in degrees F from the minimum to the maximum in one column and the corresponding temperature in degrees Celsius in another column.

Answer to Problem 22E
Solution:
• % MATLAB code to explain about the working of program.
%function file.
function explainprogram
%explain the working of the program by using the function explainprogram.
disp('In this program the maximum and minimum tempertaures are descibed in degrees Fahrenheit.')
disp('the conversion chart of temperature will be created by the program and')
disp('the conversion will be between the Fahrenheit to celsius and save the chart in a file')
disp('called Fartocel.dat')
end
% end of function
• % MATLAB code for asking the user to the minimum and maximum value of temperature in degree and Fahrenheit.
%function file.
function[minimum, maximum] = mintomaxtemp
%Ask the user to the minimum and maximum value of temperature by using the function mintomaxtemp.
minimum = input('the minimum temperature is enterted:');
%define the variable minimum.
maximum = input ('the maximum temperature is entered:');
%define the variable maximum.
[minimum, maximum] = changetemp(minimum, maximum);
end
function [minimum, maximum] = changetemp(minimum, maximum)
%Ask the user to the minimum and maximum value of temperature. in
%degree and Fahrenheit by using the function changetemp.
if maximum<minimum;
temperature = maximum;
maximum = minimum;
minimum = temperature;
end
end
% end of function
• The script file is,
%MATLAB code to write a temperature file in degrees and Fahrenheit in
%different columns and save in a data file.
%function file.
Function [F, C]=charttempertaure(minimum, maximum);
%write a temperature file in degrees and Fahrenheit in different columns by
%using the function charttemperature.
F = [minimum:maximum];
%define the variable F.
C = (F-32)*5/9;
%define the variable C;
tempchart = [F' C'];
save Fartocel.dat tempchart -ascii
end
% end of function
%The script file should be placed in the same folder.
The main script file is,
%MATLAB code to write a temperature file in a chart.
%main script file.
explainprogram
[minimum, maximum] = mintomaxtemp;
charttempertaure(minimum, maximum)
% end of file
Explanation of Solution
• A program to call a function that explains what the program will do.
In the program the minimum and maximum temperature are described in degrees and Fahrenheit. The conversion chart from Fahrenheit to Celsius will be created by the program and save in a data file.
MATLAB Code:
%MATLAB code to write a temperature file in a chart.
%main script file.
clc
clear all
close all
explainprogram
[minimum, maximum] = mintomaxtemp;
[F, C]=charttempertaure(minimum, maximum);
% end of file
%The script file should be placed in the same folder.
% MATLAB code to explain about the working of program.
%function file.
function explainprogram
%explain the working of the program by using the function explainprogram.
disp('In this program the maximum and minimum tempertaures are descibed in degrees Fahrenheit.')
disp('the conversion chart of temperature will be created by the program and')
disp('the conversion will be between the Fahrenheit to celsius and save the chart in a file')
disp('called Fartocel.dat')
end
% end of function
Save the MATLAB script with name, explainprogram.m in the current folder. Execute the script by typing the script name at the command window to generate output.
Result:
Therefore, the result is stated above.
• A program to call a function to prompt the user for the minimum and maximum temperatures in degrees Fahrenheit, and return both values.
Consider the minimum value of temperature is
MATLAB Code:
% MATLAB code for asking the user to the minimum and maximum value of temperature in degree and Fahrenheit.
%function file.
function[minimum, maximum] = mintomaxtemp
%Ask the user to the minimum and maximum value of temperature by using the function mintomaxtemp.
minimum = input('the minimum temperature is enterted:');
%define the variable minimum.
maximum = input ('the maximum temperature is entered:');
%define the variable maximum.
[minimum, maximum] = changetemp(minimum, maximum);
end
function [minimum, maximum] = changetemp(minimum, maximum)
%Ask the user to the minimum and maximum value of temperature. in
%degree and Fahrenheit by using the function changetemp.
if maximum<minimum;
temperature = maximum;
maximum = minimum;
minimum = temperature;
end
end
% end of function
Save the MATLAB script with name, mintomaxtemp.m in the current folder. Execute the script by typing the script name at the command window to generate o
Result:
Therefore, the result is stated above.
• A program to call a function to write temperature to a file as the temperature in degrees F from the minimum to the maximum in one column and the corresponding temperature in degrees Celsius in another column.
Consider the minimum value of temperature is
The conversion formula is given as,
Substitute 190 for F in the above formula.
Substitute 200 for F in the above formula.
MATLAB Code:
%MATLAB code to write a temperature file in degrees and Fahrenheit in
%different columns and save in a data file.
%function file.
function charttempertaure(minimum, maximum)
%write a temperature file in degrees and Fahrenheit in different columns by
%using the function charttemperature.
F = [minimum:maximum];
%define the variable F.
C = (F-32)*5/9;
%define the variable C;
tempchart = [F' C'];
save Fartocel.dat tempchart -ascii
end
% end of function
%MATLAB code to write a temperature file in a chart.
%main script file.
explainprogram
[minimum, maximum] = mintomaxtemp;
charttempertaure(minimum, maximum)
% end of file
Save the MATLAB script with name, charttempertaure.m and main.m in the current folder. Execute the script by typing the script name at the command window to generate output.
Result:
Therefore, the result is stated above.
Want to see more full solutions like this?
Chapter 6 Solutions
MATLAB: A Practical Introduction to Programming and Problem Solving
- Discuss and explain in the picturearrow_forwardBob and Teresa each collect their own samples to test the same hypothesis. Bob’s p-value turns out to be 0.05, and Teresa’s turns out to be 0.01. Why don’t Bob and Teresa get the same p-values? Who has stronger evidence against the null hypothesis: Bob or Teresa?arrow_forwardReview a classmate's Main Post. 1. State if you agree or disagree with the choices made for additional analysis that can be done beyond the frequency table. 2. Choose a measure of central tendency (mean, median, mode) that you would like to compute with the data beyond the frequency table. Complete either a or b below. a. Explain how that analysis can help you understand the data better. b. If you are currently unable to do that analysis, what do you think you could do to make it possible? If you do not think you can do anything, explain why it is not possible.arrow_forward
- 0|0|0|0 - Consider the time series X₁ and Y₁ = (I – B)² (I – B³)Xt. What transformations were performed on Xt to obtain Yt? seasonal difference of order 2 simple difference of order 5 seasonal difference of order 1 seasonal difference of order 5 simple difference of order 2arrow_forwardCalculate the 90% confidence interval for the population mean difference using the data in the attached image. I need to see where I went wrong.arrow_forwardMicrosoft Excel snapshot for random sampling: Also note the formula used for the last column 02 x✓ fx =INDEX(5852:58551, RANK(C2, $C$2:$C$51)) A B 1 No. States 2 1 ALABAMA Rand No. 0.925957526 3 2 ALASKA 0.372999976 4 3 ARIZONA 0.941323044 5 4 ARKANSAS 0.071266381 Random Sample CALIFORNIA NORTH CAROLINA ARKANSAS WASHINGTON G7 Microsoft Excel snapshot for systematic sampling: xfx INDEX(SD52:50551, F7) A B E F G 1 No. States Rand No. Random Sample population 50 2 1 ALABAMA 0.5296685 NEW HAMPSHIRE sample 10 3 2 ALASKA 0.4493186 OKLAHOMA k 5 4 3 ARIZONA 0.707914 KANSAS 5 4 ARKANSAS 0.4831379 NORTH DAKOTA 6 5 CALIFORNIA 0.7277162 INDIANA Random Sample Sample Name 7 6 COLORADO 0.5865002 MISSISSIPPI 8 7:ONNECTICU 0.7640596 ILLINOIS 9 8 DELAWARE 0.5783029 MISSOURI 525 10 15 INDIANA MARYLAND COLORADOarrow_forward
- Suppose the Internal Revenue Service reported that the mean tax refund for the year 2022 was $3401. Assume the standard deviation is $82.5 and that the amounts refunded follow a normal probability distribution. Solve the following three parts? (For the answer to question 14, 15, and 16, start with making a bell curve. Identify on the bell curve where is mean, X, and area(s) to be determined. 1.What percent of the refunds are more than $3,500? 2. What percent of the refunds are more than $3500 but less than $3579? 3. What percent of the refunds are more than $3325 but less than $3579?arrow_forwardA normal distribution has a mean of 50 and a standard deviation of 4. Solve the following three parts? 1. Compute the probability of a value between 44.0 and 55.0. (The question requires finding probability value between 44 and 55. Solve it in 3 steps. In the first step, use the above formula and x = 44, calculate probability value. In the second step repeat the first step with the only difference that x=55. In the third step, subtract the answer of the first part from the answer of the second part.) 2. Compute the probability of a value greater than 55.0. Use the same formula, x=55 and subtract the answer from 1. 3. Compute the probability of a value between 52.0 and 55.0. (The question requires finding probability value between 52 and 55. Solve it in 3 steps. In the first step, use the above formula and x = 52, calculate probability value. In the second step repeat the first step with the only difference that x=55. In the third step, subtract the answer of the first part from the…arrow_forwardIf a uniform distribution is defined over the interval from 6 to 10, then answer the followings: What is the mean of this uniform distribution? Show that the probability of any value between 6 and 10 is equal to 1.0 Find the probability of a value more than 7. Find the probability of a value between 7 and 9. The closing price of Schnur Sporting Goods Inc. common stock is uniformly distributed between $20 and $30 per share. What is the probability that the stock price will be: More than $27? Less than or equal to $24? The April rainfall in Flagstaff, Arizona, follows a uniform distribution between 0.5 and 3.00 inches. What is the mean amount of rainfall for the month? What is the probability of less than an inch of rain for the month? What is the probability of exactly 1.00 inch of rain? What is the probability of more than 1.50 inches of rain for the month? The best way to solve this problem is begin by a step by step creating a chart. Clearly mark the range, identifying the…arrow_forward
- Client 1 Weight before diet (pounds) Weight after diet (pounds) 128 120 2 131 123 3 140 141 4 178 170 5 121 118 6 136 136 7 118 121 8 136 127arrow_forwardClient 1 Weight before diet (pounds) Weight after diet (pounds) 128 120 2 131 123 3 140 141 4 178 170 5 121 118 6 136 136 7 118 121 8 136 127 a) Determine the mean change in patient weight from before to after the diet (after – before). What is the 95% confidence interval of this mean difference?arrow_forwardIn order to find probability, you can use this formula in Microsoft Excel: The best way to understand and solve these problems is by first drawing a bell curve and marking key points such as x, the mean, and the areas of interest. Once marked on the bell curve, figure out what calculations are needed to find the area of interest. =NORM.DIST(x, Mean, Standard Dev., TRUE). When the question mentions “greater than” you may have to subtract your answer from 1. When the question mentions “between (two values)”, you need to do separate calculation for both values and then subtract their results to get the answer. 1. Compute the probability of a value between 44.0 and 55.0. (The question requires finding probability value between 44 and 55. Solve it in 3 steps. In the first step, use the above formula and x = 44, calculate probability value. In the second step repeat the first step with the only difference that x=55. In the third step, subtract the answer of the first part from the…arrow_forward
- Glencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw HillAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell
- Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGALFunctions and Change: A Modeling Approach to Coll...AlgebraISBN:9781337111348Author:Bruce Crauder, Benny Evans, Alan NoellPublisher:Cengage LearningCollege AlgebraAlgebraISBN:9781305115545Author:James Stewart, Lothar Redlin, Saleem WatsonPublisher:Cengage Learning





