
To modify:
The script “fileex” to sum the numbers from the file and create a file in this format first.
Answer to Problem 9.1P
Solution:
The script is saved and executed as follows.
Explanation of Solution
MATLAB Code:
fid = fopen('subjexp.dat');
%Define the instruction to read information from "subjexp.dat" and open them.
if fid == -1
disp('Unsuccessful; The file is not opened')
%Define the instruction to display the unsuccessful result.
else
SUM = 0;
while ~feof(fid)
Number = strtok(fgetl(fid));
SUM = SUM + str2double(Number);
%Define the instruction to separate each line into the number code and %converts to a number before printing.
end
closeresult = fclose(fid);
%Define the instruction to check the file close for success.
if closeresult == 0
disp('successful: File is closed')
else
disp('Unsuccessful: File does not close')
%Define the if-else statement to check the condition for closing the
%file, and display the relative statement.
end
end
fprintf('The total sum of the numbers is: %.2f\n', SUM)
%Define the instruction to create the total sum of the numbers.
Save the MATLAB script with name, chapter_9_54793_9_1P.m in the current folder. Execute the script by typing the string name at the command window to modify the script “fileex” to sum the numbers from the file and create a file in this format first.
Result:

Therefore, the script is saved and executed.
Want to see more full solutions like this?
Chapter 9 Solutions
MATLAB: A Practical Introduction to Programming and Problem Solving
- Show all workings as to how the correct answer' was derived 4. Consider a large population of people from which a sample of 600 is taken and each is classified according to X = Nivel de educación (no education, primary education, secondary education, post-secondary education) and Y = Sexo (male or female). Conducting a test on the independence of the two qualitative variables (unit 5): 5. 6. Based on a past sample of 300 customers, a coffee pod factory found that 75% of its customers prefer the standard variety of coffee, while 25% prefer decaffeinated. However, it is suspected that in recent years there has been a change in customer preferences. To analyze whether this is, in fact, the case, the records of 250 customers who recently made a purchase are taken, obtaining the following results: Male Female Standard variety Decaf Number of clients 207 No education 15 30 Primary education 120 150 Secondary 90 90 education Post-secondary education 65 40 A. The null hypothesis is rejected,…arrow_forwardA group of 13 healthy children and adolescents participated in a phycological study designed to analyze the relationship between age and average total sleep time (ATST). To obtain a measure for ATST (in minutes), recordings were taken on each subject on three consecutive nights and then averaged. Results are provided to you in Sleep&Age.xlsx ✓ file. 1. (2 points) Determine the least-squares regression line for predicting average total sleep time using age. 2. (2 points) Make a scatter plot of the data with ATST on the y-axis (vertical axis) and Age on the x- axis (horizontal axis) with least squares regression line overlaid on the top (i.e.: obtain the fitted line plot). Make sure to attach the plot below. 3. (7 points) Check the assumptions for the simple linear regression. Attach any plots you used check the assumptions and comment on them. 4. (7 points) We want to see if the average sleep time decreases as the children grow older. Write the appropriate null and alternative…arrow_forwardQuestion 3 14 pts Refer to output from Question 1 to answer the following. a) (9 points) Use the output information to conduct a statistical test of the research hypothesis that for this diet preparation and length of study, there is a direct (positive) linear relationship between weight gain and amount of lysine eaten. Use a 5% level of significance. b) (5 points) Calculate a 95% confidence interval for the slope and provide an interpretation of this interval.arrow_forward
- Suppose we are interested in purchasing a multi-functioning inkjet printer. We want to see how the performance factors related to the price of the printer. Collected data from 20 printers include below information. PPM: Printing rate (pages per minutes) for a set of print jobs Price: Typical retail price (in dollars) at the time of the review. Data is not provided to you, but the default MINITAB output is provided to you. As you can see it is a partial output where you have to do some calculations using the provided information. Use the provided output to answer below questions. Regression Analysis: Price versus PPM Analysis of Variance DF Adj SS Adj MS F-Value P-Value Source Regression 1 PPM 1 74540 74540 74540 74540 21.75 0.000 21.75 0.000 Error 18 Lack-of-Fit 11 44191 Pure Error 7 17506 61697 3428 4017 2501 161 0.271 Total 19 136237 Model Summary S 58.5457 R-sq R-sq(adj) R-sq(pred) 54.71% 52.20% 42.25% Coefficients Term Coef SE Coef T-Value Constant PPM -94.2 90.9 56.4 -1.67 P-Value…arrow_forwardPlease Answer Question 3arrow_forwardPlease answer Question 5arrow_forward
- Please answer Question 2arrow_forwardA researcher is interested in studying how age (in years) associates with resting heart rate (beats per minutes) of adult men. He recruited 35 adult men and recorded their age and measured the resting heart rate (RHR). The researcher is specially interested in understanding whether the resting heart rate of older men is higher. Below MINITAB outputs are provided to you. Output 1 Output 2 Regression Equation RHR 67.89 +0.1576 Age Coefficients Regression Equation Age -78.8 +1.480 RHR Term Coef SE Coef T-Value P-Value VIF Coefficients Constant 67.89 1.42 47.90 0.000 Age 0.1576 0.0497 3.17 0.003 1.00 Term Constant -78.8 RHR 1.480 Coef SE Coef T-Value P-Value VIF 33.8 -2.33 0.467 3.17 0.026 0.003 1.00 Model Summary S R-sq R-sq(adj) R-sq(pred) 0.811306 23.33% 21.01% 13.11% Analysis of Variance Source DF Adj SS Adj MS F-Value P-Value Model Summary S R-sq R-sq(adj) R-sq(pred) 2.48678 23.33% 21.01% Analysis of Variance 10.93% Regression 1 6.609 6.6094 10.04 0.003 Source DF Adj SS Adj MS F-Value…arrow_forwardSuppose we are interested in purchasing a multi-functioning inkjet printer. We want to see how the performance factors related to the price of the printer. Collected data from 20 printers include below information. PPM: Printing rate (pages per minutes) for a set of print jobs Price: Typical retail price (in dollars) at the time of the review. Data is not provided to you, but the default MINITAB output is provided to you. As you can see it is a partial output where you have to do some calculations using the provided information. Use the provided output to answer below questions. Regression Analysis: Price versus PPM Analysis of Variance DF Adj SS Adj MS F-Value P-Value Source Regression 1 PPM 1 74540 74540 74540 74540 21.75 0.000 21.75 0.000 Error 18 Lack-of-Fit 11 44191 Pure Error 7 17506 61697 3428 4017 2501 161 0.271 Total 19 136237 Model Summary S 58.5457 R-sq R-sq(adj) R-sq(pred) 54.71% 52.20% 42.25% Coefficients Term Coef SE Coef T-Value Constant PPM -94.2 90.9 56.4 -1.67 P-Value…arrow_forward
- Please answer Question 4arrow_forwardA researcher conducts an experiment to examine the relationship between the weight gain of chickens whose diets had been supplemented by different amounts of amino acid lysine and the amount of lysine ingested. Since the percentage of lysine is known, and we can monitor the amount of feed consumed, we can determine the amount of lysine eaten. A random sample of twelve 2-week-old chickens was selected for the study. Each was caged separately and was allowed to eat at will from feed composed of a base supplemented with lysine. The ample data summarizing weight gains and amounts of lysine eaten over the test period are given below. (In the data ✓, y represents weight gain in grams, and x represents the amount of lysine ingested in grams.) Chick y X 1 14.7 0.09 2 17.8 0.14 3 19.6 0.18 4 18.4 0.15 5 20.5 0.16 6 21.1 0.23 7 17.2 0.11 8 18.7 0.19 9 20.2 0.23 10 16.0 0.13 11 17.8 0.17 12 19.4 0.21 1. (3 points) Create a scatterplot of the data using Minitab and paste it below. Does a linear…arrow_forwardChildren develop different patterns of attachment based on interactions with their caregivers at young age (Wikipedia). Certain study attempt to find the association between Child Care and Attachment Pattern Classification. Below table summarizes the collected data. Hours in Child Care Low Moderate High Attachment Pattern (0-3 hours) (4-19 hours) (20-54 hours) Secure 24 35 5 Anxious 11 10 8 Carryout an appropriate test to see if there is an association between amount of time spend on Child Care and Attachment Pattern of the children. 6. In order to answer the same research question as in previous parts in this problem, can we do a hypothesis test for comparing two independent proportions while keeping the existing categories as they are? Explain your answer rather than simply saying "yes" or "no".arrow_forward
Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell
Mathematics For Machine TechnologyAdvanced MathISBN:9781337798310Author:Peterson, John.Publisher:Cengage Learning,
Holt Mcdougal Larson Pre-algebra: Student Edition...AlgebraISBN:9780547587776Author:HOLT MCDOUGALPublisher:HOLT MCDOUGAL
Trigonometry (MindTap Course List)TrigonometryISBN:9781305652224Author:Charles P. McKeague, Mark D. TurnerPublisher:Cengage Learning
Elementary AlgebraAlgebraISBN:9780998625713Author:Lynn Marecek, MaryAnne Anthony-SmithPublisher:OpenStax - Rice University





