Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A team of engineers is designing a bridge to span the Podunk River. As part of t

ID: 3817655 • Letter: A

Question

A team of engineers is designing a bridge to span the Podunk River. As part of the design process, the local flooding data must be analyzed. The following information on each storm that has been recorded in the past 40 years is stored in a file: a code for the location of the source of the data, the amount of rainfall (in inches), and the duration of the storm (in hours) e in that order. For example, the file might look like this:

321 2.4 1.5 111 3.3 12.1 etc.

IN MATLAB:

Create a data file. Write the first part of the program: design a data structure to store the storm data from the file, and also the intensity of each storm. The intensity is the rainfall amount divided by the duration. Write a function to read the data from the file (use load), copy from the matrix into a vector of structs, and then calculate the intensities. Write another function to print all of the information in a neatly organized table.

Add a function to the program to calculate the average intensity of the storms.

Add a function to the program to print all of the information given on the most intense storm. Use a subfunction for this function that will return the index of the most intense storm

To remain competitive, every manufacturing enterprise must maintain strict quality control measures. Extensive testing of new machines and products must be incorporated into the design cycle. Once manufactured, rigorous testing for imperfections and documentation is an important part of the feedback loop to the next design cycle.

Explanation / Answer

We have to first create a data file, say, myfile.txt with the followind data entered.

Datasource AmtofRainfall Duration

321 2.4 1.5
111 3.3 12.1
345 5.7 19

We create a cell array of variable names to load.

The variables Datasource,AmtofRainfall,Duration are loaded into the structure array, S.

function calcIntensity = Intensity(S, fieldname1, fieldname2)
for k = 1:numel(S)
S(k).(TotalIntensity) = S(k).(fieldname1)/S(k).(fieldname2);

end

>>S=Intensity(S,'AmtofRainfall','Duration')

>>T=struct2table(S)

Datasource AmtofRainfall Duration TotalIntensity

________ ______ __________ ___________

321 2.4 1.5 1.6

111 3.3 12.1 0.27

345 5.7 19 0.3

Next, we have to write a function to calculate the average intensities of the storms.

function avgIntensity = AverageInt(S, fieldname1)
for k = 1:numel(S)
S(k).(AverageIntensity) = mean([S.(TotalIntensity(k))]);

end

>>averageIntensity=AverageInt(S,'TotalIntensity')

>>ans=

0.7233

We have to develop a subfunction in our new function which will return the index of the most intense storm and also its other field details.

function [printData,mostIntense] = Intensity(S, fieldname1)

%primary function

printData=print(S,fieldname);

mostIntense=Intense(S,fieldname)

%subfunction printData

function a=printData(S,field)

n= numel([s(:).(field)])

a=extractfields(S,field)

}

end

%subfunction mostIntense

function mostIntense=Intense(S,field)

for k=1:numel(S)

mostIntense=max(getfield(S,'TotalIntensity'));

fprintf('Index of most intense storm: %d',mostIntense)

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote