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

Problem Inputs : (with units) ace_data % matrix of storm data ******************

ID: 3530068 • Letter: P

Question

Problem Inputs

: (with units)

ace_data % matrix of storm data

******************************************************************************

Problem Outputs:

(with units)

ace_date

array

ACE values greater than the average ACE value

years and #tropical storms for #TS > average #tropical storms

************************************************************************************************

Other variables:

(with units)

average ACE value

average number of tropical storms

results of

find()

Equations:

none

***********************************************************************************************

Algorithm: C

opy and paste the following as comments in your program. Use blank lines in code to separate sections of work

.

open the file

if not good open,

print message from fopen (program should end)

else

read data one number at a time and save into a matrix

print info from matrix one row at a time

find and print number of ACE values > average ACE

find and print years and #tropical storms for #TS > average #tropical storms

end

***************************************************************************************************************************

Sample Input and Output:

Atlanta Basin Hurricane Seasons 2001-2010

ACE #Tropical

Year Index Storms

---- ----- ---------

2001 106 15

2002 65 12

2003 175 16

2004 225 14

2005 248 28

2006 7910

2007 72 15

2008 145 16

2009 51 9

2010 62 7

4 ACE values are greater than the average AVE, 122.80

Years with Above Average Number of Tropical Storms

Year # Tropical Storms

2001 15

2003 16

2005 28

2007 15

2008 16

Explanation / Answer

% Problem Constants: (with units)

FIRST_YEAR = 2001; % first year of data

LAST_YEAR = 2010; % last year of data

FILENAME = 'ace_data06.txt';

% open the file

[fid,msg] = fopen(FILENAME, 'r');


if (strcmpi(msg,'') ==0)% if not good open,

fprintf('%s',msg);% print message from fopen (program should end)

return;

else

years=LAST_YEAR-FIRST_YEAR+1;

ace_data= zeros(years,2);

% read data one number at a time and save into a matrix

for i=1:years

for j=1:3

ace_data(i,j)=fscanf(fid,'%d',1);

end

end

fprintf('Atlanta Basin Hurricane Seasons %d-%d ',FIRST_YEAR,LAST_YEAR);

fprintf('ACE #Tropical Year Index Storms ');

fprintf('---- ----- --------- ');

%print info from matrix one row at a time


% print info from matrix one row at a time

for i=1:years

fprintf('%d %d %d ',ace_data(i,1),ace_data(i,2),ace_data(i,3));

end

end


avgAce=mean(ace_data(:,2));%average of indexes

avgTropical=mean(ace_data(:,3));%averager tropical storm


avgAceCount=0;

% find and print number of ACE values > average ACE

for i=1:years

if(ace_data(i,2)>avgAce)

avgAceCount= avgAceCount+1;

end

end

fprintf('%d ACE values are greater than the average AVE, %.2f ',avgAceCount,avgAce);



fprintf('Years with Above Average Number of Tropical Storms ');

fprintf('Year # Tropical Storms ');

% find and print years and #tropical storms for #TS > average #tropical storms

for i=1:years

if(ace_data(i,3)>avgTropical)

fprintf('%d %d ',ace_data(i,1),ace_data(i,3));

end

end



% 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