
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
- . This problem will yield a standard formula given in elementary statistics for a least squares line, making use of the normal equations. (a) Given pairs of data points (x1, Y1), (x2, Y2), ..., (xn, Yn) consider approximating lines of the form y = mx+b. The error e; for the ith pair is the distance between y; and the height (y value) of the line at xi. This is ei = Yi — (mxi + b). If we consider the equations b + x;m = Yi for i n in the variables b and m we can = 1,2, = think of this as a system of equations Ax = 6 where A 1 x1 x2 = : [m] Хп Y1 Уп numbers. Here, note that the variables are m and b and the xi, Yi are given The least squares approximation for this system (which gives the intercept b and slope m of the best least squares line for the data) is the solution to the normal equations AT Ax = ATb. Determine ATA (a 2×2 matrix) and AT (a 2×1 matrix). The entries will be sums of terms involving the x; and y₁. Write these, first using Σ notation and then simplify the notation using…arrow_forward= a) Recall that the formula for the projection p of vector & onto vector a is p = ±ªã. The plane through the origin in R³ given by ax+by+cz = 0 for real numbers a, b, c, is the set of all points (viewed as vectors) orthogonal to the normal n = (a, b, c) to the plane. To find the distance from a point w (xo, Yo, zo) to the plane ax+by+cz = 0 we can find the projection of w onto the normal ñ and then find the length of this projection. Do this to derive a generic formula for the distance in terms of xo, Yo, Zo, a, b, c. First find the length squared and then take a root. b) To find the distance from a point w (xo, Yo, zo) to a plane ax + by + cz = d, not necessarily not through the origin, one approach is to shift all z coordinates down by d. That is, replace (x, y, z) by (x, y, z — d). The relationship between the plane and w is unchanged so we can find the distance by finding the distance between (xo, Yo, zo - d) and the plane ax + by+cz = 0 through the origin. Do this to derive a…arrow_forwardUse Gram-Schmidt orthogonalization to find an orthonormal set of vectors with the same span as = 1 2 -0-08-0 a2 = 3 a3 = -2 Find also a QR factorization A = QR with the columns of Q the orthonormal set found above and R upper triangular and invertible and A with columns ā₁, ā2, ā3.arrow_forward
- (a) Let Q be an orthonormal matrix. That is, the columns of Q have unit length and are pairwise orthogonal. Prove that the length of Qã is equal to the length of for any column vector x. Note that you can do this by showing that the lengths squared are equal. (b) Prove that if A and B are symmetric and πT Ax = x² Bã for all & then A = B. Make use of coordinate vectors ē;, which are 0 except for a 1 in position i. Explain why, for matrix A, entries can be found by arj = Aej. First show that diagonal = = entries aii bir. Then consider what (ē¿ + ē¿)ªA(ē¿ + ē¿) in terms of entries of A (and similarly for B) and make use of symmetry aij = aji and similarly for B. (c) Prove the converse: If for all x, ||Q|| ||||| then Q is orthonormal. One ap- proach is to use part (b) to show that QTQ = I. Recall that QTQ is symmetric (and trivially I is symmetric). Recall also that, written in matrix notation, vector length (squared) is given by ||7||2 = (this is the dot product written in matrix…arrow_forward(a) What is wrong with the following statement and proof? A is invertible if and only if ATA is invertible. 'Proof': Since det(A) = det(AT), det(ATA) = det(A)². Either both are 0 (and both A and ATA are not invertible) or both are nonzero (and both A and ATA are invertible). (b) Prove that Null(A) C Null(ATA). That is, prove that if Ax = 0 then AT Ax = 0. (c) Prove that Null(ATA) C Null(A). That is, prove that if AT Añ = 0 then Aã = Ổ. Recall that the length (squared) of a vector v is V, which written in matrix multiplication notation is Tv. (d) Parts (b) and (c) imply that Null(A) = • Nul(ATA). Use this to prove that the columns of A are linearly independent if and only if ATA has an inverse.arrow_forwardGive a 99% confidence interval, for μ1 M2 given the following information. n₁ = 20, 1 = 2.31, s₁ = 0.47 n2 = 40, 2 = 2.21, 82 = 0.55 + Use Technology Rounded to 2 decimal places. Hint Question Help: Video Submit Question ch Η UP T SINK O DELL F2 F3 F4 F5 F6 F7 F8 144 ►11 4arrow_forward
- Please could you provide solutions to the following questions. Thanksarrow_forwardPlease could you provide solutions to the following questions. Thanksarrow_forwardor Beer and blood alcohol content: Many people believe that gender, weight, drinking habits, and many other factors are much more important in predicting blood alcohol content (BAC) than simply considering the number of drinks a person consumed. Here we examine data from sixteen student volunteers at Ohio State University who each drank a randomly assigned number of cans of beer. These students were evenly divided between men and women, and they differed in weight and drinking habits. Thirty minutes later, a police officer measured their blood alcohol content (BAC) in grams of alcohol per deciliter of blood (Malkevitc and Lesser, 2008). The scatterplot and regression table summarize the findings. to search BAC (grams per deciliter) 0.15- 0.10- 0.05- Part of Ti Calculator Output Ti Calculator y = ax+b Be and p = 0 t = 7.48 P 0.0000 df = 14 a = 0.0180 b = -0.0127 Part of Excel Output 2 4 0 0 6 Cans of beer (Intercept) beers Estimate -0.0127 0.0180 Std. Error t value 0.0126 P(>|t|) -1.00…arrow_forward
- Proctor ts Ces rces arch Question 31 The data below was collected from manufacturer advertisements of their vehicles horsepower (x) and highway gas mileage (mpg=y). Use this data to answer the following questions. horsepower 157 250 340 350 390 190 220 mpg 33 28 15 17 11 35 42 1. Find the p-value to determine if there is a linear correlation between horsepower and highway gas mileage (mpg). Record the p-value below. Round to four decimal places. p-value= 2. Is there a linear correlation between horsepower and highway gas mileage (mpg)? ? 3. If there is a linear correlation, write the correlation coefficient below. Otherwise, leave it blank. Round your final answer to four decimal places. Be careful with your sign. T= 4. If there is a linear correlation, write the regression equation below. Otherwise, leave it blank. Round all numbers to four decimal places. ŷ 5. Using the data shown above, predict the the highway gas mileage (mpg) for a car that has a horsepower of 225. Round your…arrow_forwardarch es For Question 24 < Annual high temperatures in a certain location have been tracked for several years. Let X represent the number of years after 2000 and Y the high temperature. Based on the data shown below, calculate the linear regression equation using technology (each number to three decimal places). X y 4 33.38 5 31 6 31.92 7 33.64 8 33.06 9 32.28 10 33.7 11 30.82 12 31.14 13 32.56 14 34.58 Click Download CSV to download csv file of data or copy/paste the data into Excel. After downloading the file, you may want to save it as an Excel Workbook. The fitted regression equation is ŷ = Interpret the y-intercept of the equation: O In 2000, the temperature was about 32.152. In 2014, the temperature was about 34.58. In 2004, the temperature was about 32.152. In 2004, the temperature was about 0.045. Question Help: Video Submit Question F2 F3 F4 144 UP T M F5 114 % L F6 144 DOLL F7 6 F8 F9 F10 &arrow_forwardMath 105Z Worksheet Week 8 Instructions: Answer questions about the following contexts. You'll be graded for accuracy on problems 3 and 4 but you should try to complete the entire worksheet for full credit (see the rubric on Canvas). You'll need to upload your work as a single PDF to the appropriate assignment in Canvas. 1. A random sampling of the speeds of 12 cars monitored on a small stretch of highway yielded the following data: 45 55 50 60 60 55 60 50 70 65 55 60 (a) Find the mean speed. (b) Find the median speed. (c) Find the mode speed. (d) Construct a histogram to represent the data. 2. The mean exam score for the 24 students in section M is 72, and the mean exam score for the 30 students of section N is 78. Find the mean score for all 54 students. Page 1arrow_forward
Glencoe Algebra 1, Student Edition, 9780079039897...AlgebraISBN:9780079039897Author:CarterPublisher:McGraw Hill
Algebra: 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 MCDOUGAL
Functions and Change: A Modeling Approach to Coll...AlgebraISBN:9781337111348Author:Bruce Crauder, Benny Evans, Alan NoellPublisher:Cengage Learning
College AlgebraAlgebraISBN:9781305115545Author:James Stewart, Lothar Redlin, Saleem WatsonPublisher:Cengage Learning





