
To write:
A

Answer to Problem 27E
Solution:
The file is,
%MATLAB code to load the data and create a data structure file.
%structure file.
stormdata = [321 2.4 1.5]
save stormdata.dat stormdata -ascii
stormdata = [111 3.3 12.1]
save stormdata.dat stormdata -ascii
clear
load stormdata.dat
%end of function file
%The function file should be placed in the same folder
The function file is,
%MATLAB code to print a table between stormdatavector and intensity.
%function file.
function tableprint(stormdatavector, intensity)
for i = 1:length(stormdatavector)
fprintf('%20.1f\t%20.1f\t%20.1f|t%20f\n', stormdatavector(i).locationcode, stormdatavector(i).rainfallamount, stormdatavector(i).stormduration, intensity(i))
end
end
%end of function file
%The function file should be placed in the same folder.
The function file is,
%MATLAB code to calculate the average intensity.
%function file.
function avgintensity(intensity)
intensitysum = 0;
for i = 1:length(intensity)
intensitysum = intensitysum + intensity(i);
end
avgintensity = intensitysum/length(intensity);
fprintf('Average intensity of storm is %f\n', avgintensity)
end
%end of function file
%The function file should be placed in the same folder.
The function file is,
%MATLAB code to find the information about mostintensestorm.
%function file.
function mostintensestorm(stormvector, intensity)
for i = 1:length(intensity)
for j = i + 1:length(intensity)
if intensity(i)>intensity(j)
temp = intensity(i);
intensity(i) = intensity (j);
intensity(j) = temp;
end
end
end
fprintf('the information of most intense storm is:%f\n', intensity(length(intensity)))
tempindex = index(stormvector, intensity);
fprintf('the index of most intense storm is:%d\n', tempindex);
fprintf('%20s|t%20s\t%20s\t%20s\n','location code','rainfall amount','storm duration','intensities')
fprintf('%20.1f\t%20.1f\t%20.1f\t%20f\n', stormvector(tempindex).locationcode, stormvector(tempindex).rainfallamount, stormvector(tempindex).stormduration, intensity(length(intensity)))
end
function index = index(stormvector, intensity)
for i = 1:length(stormvector)
if intensity(length(intensity)) ==stormvector(i).rainfallamount/stormvector(i).stormduration
index = i;
break;
end
end
end
%end of function file
%The function file should be placed in the same folder.
The function file is,
%MATLAB code to find the output.
%function file.
fprintf('%20s\t%20s\t%20s\t%20s\n','location code','rainfall amount','storm duration','intensities')
for i = 1:size(stormdata, 1)
for j = 1:length(stormdata(i))
stormvector(i) = struct('locationcode', stormdata(i, j),'rainfallamount', stormdata(i, j+1),'stormduration', stormdata(i, j+2));
intensity(i) = stormvector(i).rainfallamount/stormvector(i).stormduration;
end
end
tableprint(stormvector, intensity)
avgintensity(intensity)
mostintensestorm(stormvector, intensity)
%end of function file
%The function file should be placed in the same folder.
Explanation of Solution
The output is,
The average intensity is,
The location code is,
The rainfall amount is,
MATLAB Code:
clc
clear all
close all
%MATLAB code to load the data and create a data structure file.
%structure file.
stormdata = [321 2.4 1.5]
save stormdata.dat stormdata -ascii
stormdata = [111 3.3 12.1]
save stormdata.dat stormdata -ascii
clear
load stormdata.dat
%end of structure file
%The file should be placed in the same folder
output;
%The function file should be placed in the same folder
%MATLAB code to print a table between stormdatavector and intensity.
%function file.
function tableprint(stormdatavector, intensity)
for i = 1:length(stormdatavector)
fprintf('%20.1f\t%20.1f\t%20.1f|t%20f\n', stormdatavector(i).locationcode, stormdatavector(i).rainfallamount, stormdatavector(i).stormduration, intensity(i))
end
end
%end of function file
%The function file should be placed in the same folder.
%MATLAB code to calculate the average intensity.
%function file.
function avgintensity(intensity)
intensitysum = 0;
for i = 1:length(intensity)
intensitysum = intensitysum + intensity(i);
end
avgintensity = intensitysum/length(intensity);
fprintf('Average intensity of storm is %f\n', avgintensity)
end
%end of function file
%The function file should be placed in the same folder.
%MATLAB code to find the information about mostintensestorm.
%function file.
function mostintensestorm(stormvector, intensity)
for i = 1:length(intensity)
for j = i + 1:length(intensity)
if intensity(i)>intensity(j)
temp = intensity(i);
intensity(i) = intensity (j);
intensity(j) = temp;
end
end
end
fprintf('the information of most intense storm is:%f\n', intensity(length(intensity)))
tempindex = index(stormvector, intensity);
fprintf('the index of most intense storm is:%d\n', tempindex);
fprintf('%20s|t%20s\t%20s\t%20s\n','location code','rainfall amount','storm duration','intensities')
fprintf('%20.1f\t%20.1f\t%20.1f\t%20f\n', stormvector(tempindex).locationcode, stormvector(tempindex).rainfallamount, stormvector(tempindex).stormduration, intensity(length(intensity)))
end
function index = index(stormvector, intensity)
for i = 1:length(stormvector)
if intensity(length(intensity)) ==stormvector(i).rainfallamount/stormvector(i).stormduration
index = i;
break;
end
end
end
%end of function file
%The function file should be placed in the same folder.
%MATLAB code to find the output.
%function file.
fprintf('%20s\t%20s\t%20s\t%20s\n','location code','rainfall amount','storm duration','intensities')
for i = 1:size(stormdata, 1)
for j = 1:length(stormdata(i))
stormvector(i) = struct('locationcode', stormdata(i, j),'rainfallamount', stormdata(i, j+1),'stormduration', stormdata(i, j+2));
intensity(i) = stormvector(i).rainfallamount/stormvector(i).stormduration;
end
end
tableprint(stormvector, intensity)
avgintensity(intensity)
mostintensestorm(stormvector, intensity)
%end of function file
%The function file should be placed in the same folder.
Save the MATLAB script with name, chapter8_54793_8_27E.m and function files with names tableprint.m, avgintensity.m, mostintensestorm.m and output.m in the current folder. Execute the functions by typing the functions name at the command window to generate output.
Result:
The result is,
Therefore, the result is stated above.
Want to see more full solutions like this?
Chapter 8 Solutions
Matlab, Fourth Edition: A Practical Introduction to Programming and Problem Solving
- Rose Par posted Apr 5, 2025 9:01 PM Subscribe To: Store Owner From: Rose Par, Manager Subject: Decision About Selling Custom Flower Bouquets Date: April 5, 2025 Our shop, which prides itself on selling handmade gifts and cultural items, has recently received inquiries from customers about the availability of fresh flower bouquets for special occasions. This has prompted me to consider whether we should introduce custom flower bouquets in our shop. We need to decide whether to start offering this new product. There are three options: provide a complete selection of custom bouquets for events like birthdays and anniversaries, start small with just a few ready-made flower arrangements, or do not add flowers. There are also three possible outcomes. First, we might see high demand, and the bouquets could sell quickly. Second, we might have medium demand, with a few sold each week. Third, there might be low demand, and the flowers may not sell well, possibly going to waste. These outcomes…arrow_forwardConsider the state space model X₁ = §Xt−1 + Wt, Yt = AX+Vt, where Xt Є R4 and Y E R². Suppose we know the covariance matrices for Wt and Vt. How many unknown parameters are there in the model?arrow_forwardBusiness Discussarrow_forward
- You want to obtain a sample to estimate the proportion of a population that possess a particular genetic marker. Based on previous evidence, you believe approximately p∗=11% of the population have the genetic marker. You would like to be 90% confident that your estimate is within 0.5% of the true population proportion. How large of a sample size is required?n = (Wrong: 10,603) Do not round mid-calculation. However, you may use a critical value accurate to three decimal places.arrow_forward2. [20] Let {X1,..., Xn} be a random sample from Ber(p), where p = (0, 1). Consider two estimators of the parameter p: 1 p=X_and_p= n+2 (x+1). For each of p and p, find the bias and MSE.arrow_forward1. [20] The joint PDF of RVs X and Y is given by xe-(z+y), r>0, y > 0, fx,y(x, y) = 0, otherwise. (a) Find P(0X≤1, 1arrow_forward4. [20] Let {X1,..., X} be a random sample from a continuous distribution with PDF f(x; 0) = { Axe 5 0, x > 0, otherwise. where > 0 is an unknown parameter. Let {x1,...,xn} be an observed sample. (a) Find the value of c in the PDF. (b) Find the likelihood function of 0. (c) Find the MLE, Ô, of 0. (d) Find the bias and MSE of 0.arrow_forward3. [20] Let {X1,..., Xn} be a random sample from a binomial distribution Bin(30, p), where p (0, 1) is unknown. Let {x1,...,xn} be an observed sample. (a) Find the likelihood function of p. (b) Find the MLE, p, of p. (c) Find the bias and MSE of p.arrow_forwardGiven the sample space: ΩΞ = {a,b,c,d,e,f} and events: {a,b,e,f} A = {a, b, c, d}, B = {c, d, e, f}, and C = {a, b, e, f} For parts a-c: determine the outcomes in each of the provided sets. Use proper set notation. a. (ACB) C (AN (BUC) C) U (AN (BUC)) AC UBC UCC b. C. d. If the outcomes in 2 are equally likely, calculate P(AN BNC).arrow_forwardSuppose a sample of O-rings was obtained and the wall thickness (in inches) of each was recorded. Use a normal probability plot to assess whether the sample data could have come from a population that is normally distributed. Click here to view the table of critical values for normal probability plots. Click here to view page 1 of the standard normal distribution table. Click here to view page 2 of the standard normal distribution table. 0.191 0.186 0.201 0.2005 0.203 0.210 0.234 0.248 0.260 0.273 0.281 0.290 0.305 0.310 0.308 0.311 Using the correlation coefficient of the normal probability plot, is it reasonable to conclude that the population is normally distributed? Select the correct choice below and fill in the answer boxes within your choice. (Round to three decimal places as needed.) ○ A. Yes. The correlation between the expected z-scores and the observed data, , exceeds the critical value, . Therefore, it is reasonable to conclude that the data come from a normal population. ○…arrow_forwardding question ypothesis at a=0.01 and at a = 37. Consider the following hypotheses: 20 Ho: μ=12 HA: μ12 Find the p-value for this hypothesis test based on the following sample information. a. x=11; s= 3.2; n = 36 b. x = 13; s=3.2; n = 36 C. c. d. x = 11; s= 2.8; n=36 x = 11; s= 2.8; n = 49arrow_forward13. A pharmaceutical company has developed a new drug for depression. There is a concern, however, that the drug also raises the blood pressure of its users. A researcher wants to conduct a test to validate this claim. Would the manager of the pharmaceutical company be more concerned about a Type I error or a Type II error? Explain.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal LittellElementary Geometry For College Students, 7eGeometryISBN:9781337614085Author:Alexander, Daniel C.; Koeberlein, Geralyn M.Publisher:Cengage,

