Question

In: Computer Science

%% Homework A8_HW % Analyze hurricaine data over 2001-2014 and 2015-2020 time periods.% The data are...

%% Homework A8_HW % Analyze hurricaine data over 2001-2014 and 2015-2020 time periods.% The data are provided in 2 csv files containing years and number of% hurricaines for each year in sequential order, i.e.,: 2001 4 2002 6 ...% Download the 2 csv files AtlanticHurricanes20012014.csv and% AtlanticHurricanes20152020.csv and place them in the same folder % with your m-fileclearclc% read 2 csv files into 2 arrays hurr1 and hurr2filename = 'AtlanticHurricanes20012014.csv';hurr1 = csvread(filename);filename = 'AtlanticHurricanes20152020.csv';hurr2 = csvread(filename);%% 1.Find and print the number of years in each of the two arrays%% 2. Using "reshape" and "transpose" functions, reshape the two arrays % into 2-column arrays where the first column is the year number, and % the second column is the corresponding number of hurricanes for that year%% 3. Combine the two 2-column arrays into a new single 2-column array hurrAll%% 4. Print the combined array hurrAll using the disp function % (print headings for each column)%% 5. Sort the combined array hurrAll row-by-row based on % the number of hurricanes in ascending order and print the array%% 6. Using "find" function, find the years with minimal and maximal % numbers of hurricanes. Print these years along with respective % hurricaine numbers using "fprintf" function

This is MATLAB and the documents are a single row array as follows: (THIS IS THE INFO NEEDING TO BE SORTED)

hurr1 = 2010 9 2011 8 2012 7 2013 6

hurr2 = 2014 6 2015 7 2016 8 2017 9

Solutions

Expert Solution

clear
clc
filename = 'AtlanticHurricanes20012014.csv';
hurr1 = csvread(filename);
filename = 'AtlanticHurricanes20152020.csv';
hurr2 = csvread(filename);
%for testing
%hurr1 = [2010 9 2011 8 2012 7 2013 6];
%hurr2 = [2014 6 2015 7 2016 8 2017 9];

%% 1.Find and print the number of years in each of the two arrays
fprintf('Number of years in hurr1: %d\n',length(hurr1)/2);
fprintf('Number of years in hurr2: %d\n',length(hurr2)/2);

%% 2. Using "reshape" and "transpose" functions, reshape the two arrays % into 2-column arrays where the first column is the year number,
% and % the second column is the corresponding number of hurricanes for that year
hurr1=reshape(hurr1,2,4)';
hurr2=reshape(hurr2,2,4)';

%% 3. Combine the two 2-column arrays into a new single 2-column array hurrAll
hurrAll = [hurr1;hurr2];

%% 4. Print the combined array hurrAll using the disp function % (print headings for each column)
disp(' Year hurricanes')
disp(hurrAll)

%% 5. Sort the combined array hurrAll row-by-row based on % the number of hurricanes in ascending order and print the array
hurrAll = sortrows(hurrAll,2);
disp(' Year hurricanes')
disp(hurrAll)

%% 6. Using "find" function, find the years with minimal and maximal % numbers of hurricanes.
% Print these years along with respective % hurricaine numbers using "fprintf" function
maxInd = find(hurrAll(:,2)==max(hurrAll(:,2)));
minInd = find(hurrAll(:,2)==min(hurrAll(:,2)));
fprintf('Years with maximum hurricanes\n')
fprintf('year: %d hurricanes: %d\n',hurrAll(maxInd,:)')
fprintf('Years with minimum hurricanes\n')
fprintf('year: %d hurricanes: %d\n',hurrAll(minInd,:)')


Related Solutions

Below are the quality costs data for a company for 2014 & 2015 2014 2015 Prevention...
Below are the quality costs data for a company for 2014 & 2015 2014 2015 Prevention $90,000 $110,000 Appraisal $50,000 $62,000 Internal Faliure $40,000 $34,000 External Faliure $62,000 $60,000 Sales: $5,100,000 $5,350,000 A) whats the precentage change in the total quality index between 2014 & 2015 B) What is the percentage change in the precention quality index between 2014 & 2015 C) What is the percentage change in the internal faliure quality index between 2014 & 2015 ? D) Do...
Below are the quality costs data for a company for 2014 & 2015 2014 2015 Prevention...
Below are the quality costs data for a company for 2014 & 2015 2014 2015 Prevention $90,000 $110,000 Appraisal $50,000 $62,000 Internal Faliure $40,000 $34,000 External Faliure $62,000 $60,000 Sales: $5,100,000 $5,350,000 A) whats the precentage change in the total quality index between 2014 & 2015 B) What is the percentage change in the precention quality index between 2014 & 2015 C) What is the percentage change in the internal faliure quality index between 2014 & 2015 ? D) Do...
Below are data for countries with fast and slow growth rates over two different time periods....
Below are data for countries with fast and slow growth rates over two different time periods. Construct a bar chart for each country in both categories. In other words, you will end up with four different bar charts, two for each of the two categories of the countries representing both time periods. Country Average Growth Rate of Real GDP 1990–2000 Average Growth Rate of Real GDP 2000–2008 Fast Growth Club (5% or more per year in both time periods) Cambodia...
Macroeconomic data for the country of XYZ for the years 2014 and 2015 are given as...
Macroeconomic data for the country of XYZ for the years 2014 and 2015 are given as 2014 2015 Output 12,000 tons of carrots 20,000 tons of carrots Unemployed 100 workers 50 workers Unemployment rate 5% 2% Population 4000 people 4400 people Assume that XYZ produces only carrots. What is the difference in labour force between 2014 and 2015? a) 250 workers b) 400 workers c) 500 workers d) None of the above
Macroeconomic data for the country of XYZ for the years 2014 and 2015 are given as...
Macroeconomic data for the country of XYZ for the years 2014 and 2015 are given as 2014 2015 Output 12,000 tons of carrots 20,000 tons of carrots Unemployed 100 workers 50 workers Unemployment rate 5% 2% Population 4000 people 4400 people Assume that XYZ produces only carrots. What is the growth rate of average labour productivity between 2014 and 2015? (Show your calculation Question 31 options: a) Around 39.31% b) Around 19.31% c) Around 29.31% d) None of the above
The data show the number of U.S. space launches for the 10-year periods from 1960 to 2009. Construct a time series graph for the data and analyze the graph.
The data show the number of U.S. space launches for the 10-year periods from 1960 to 2009. Construct a time series graph for the data and analyze the graph.
While the evidence suggests that over long periods of time that stocks will outperform bonds, individuals...
While the evidence suggests that over long periods of time that stocks will outperform bonds, individuals with a long-term investment horizon may still choose to invest in bonds. Is this rational behavior? Why or why not? Give real world example
While the evidence suggests that over long periods of time that stocks will outperform bonds, individuals...
While the evidence suggests that over long periods of time that stocks will outperform bonds, individuals with a long-term investment horizon may still choose to invest in bonds. Is this rational behavior? Why or why not?
While the evidence suggests that over long periods of time that stocks will outperform bonds, individuals...
While the evidence suggests that over long periods of time that stocks will outperform bonds, individuals with a long-term investment horizon may still choose to invest in bonds. Is this rational behavior? Why or why not?
The amount of oxygen consumption was measured in seven individuals over two periods of time while...
The amount of oxygen consumption was measured in seven individuals over two periods of time while sitting with their eyes closed. During the first period, they listened to an exciting adventure story; during the second period of time, they heard restful music. The researcher is not sure whether participants will consume more or less oxygen during the story compared with the music. Here are their results: Subject Story Music 1 5.8 5.3 2 8.1 7.2 3 6.4 6.3 4 7.8...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT