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

Function Name: theRatio % Inputs (1): - (double) A 3XN array of information of T

ID: 3648431 • Letter: F

Question

Function Name: theRatio
% Inputs (1): - (double) A 3XN array of information of Tech demographics
% Outputs (1): - (double) A vector of the time interval that saw the
% largest overall growth of women to total
% population
%
% Function Description:
% Everybody knows that when they walk around campus, they are walking
% into the land of mystery. Nobody knows quite what they'll see, but
% there's one thing for certain that they won't: Girls.
%
% Every year Georgia Tech states, "We have a record number of women
% enrolled this year, up by...blah blah blah." No matter how many times
% they say this, it still doesn't appear that "The Ratio" (that is number
% of guys to girls) is getting better. Is this just some hoax Georgia
% Tech is pulling on us? We will let you be the judge.
%
% Given an array of information of Tech demographics over the years,
% write a function called 'theRatio' that will determine which time
% interval saw the largest growth of females to the overall growth of the
% Georgia Tech population.
%
% The input array a 3xN array. The first row is the year, the second row
% is the total number of students at Georgia Tech, and the third row is
% the number of females at Georgia Tech. Each column represents the data
% from a different year in ascending order. Two consecutive columns
% represents one time interval.
%
% The output will be a 1x2 vector of the time interval that saw the
% largest overall positive growth of women to total population.
%
% Example:
% In 1950, there were 6,745 students at Georgia Tech of which 745 were
% girls and in 1965 there were 8,231 students of which 941 girls. The
% change in the ratio between this time interval would be:
%
% (941 - 745) / (8,231 - 6,745), or 0.132
%
% If this was the largest postive change, then the output would be [1950,
% 1965].
%
% Hints:
% - You may find the function diff() or your recently written function
% myDiff() useful for this problem.
%
% Test Cases:
% A = [2006, 2007, 2008, 2009, 2010, 2011;
% 17935, 18742, 19413, 20291, 20720, 20941;
% 4969, 5316, 5518, 5772, 6055, 6283];
%
% B = [1885, 1925, 1955, 1967, 1980, 1995;
% 84, 723, 2334, 3784, 8123, 14172;
% 0, 14, 156, 224, 829, 1171];
%
% [interval1] = theRatio(A);
% interval1 => [2010, 2011]
%
% [interval2] = theRatio(B);
% interval2 => [1967, 1980]

Explanation / Answer

function womengrowth=theRatio(info)% [year;tot student;females] [~,col]=size(info); for n=1:col-1 dgirls=info(3,n+1)-info(3,n); dtot=info(2,n+1)-info(2,n); cal(n)=dgirls/dtot; end [~,pos]=max(cal); womengrowth=[info(1,pos),info(1,pos+1)];