close all clc clear %% Warmup Problem x = linspace(-5*pi,5*pi,1000); y1 = cos(x); y2 = 2 * sin(x - pi/2); figure plot(x,y1,"r--",x,y2,"b-") title("y1 = cos(x) and y2 = 2sin(x-pi/2)") xlabel("x") ylabel("y1 and y2") legend("y1 = cos(x)", "y2 = 2sin(x-pi/2)") %% Application Problem % income = readmatrix("US_Income_Inequality_Data.xlsx"); wealth = readmatrix("US_Wealth_Inequality_Data.xlsx"); figure subplot(2,1,1) hold on plot(income(:,1),income(:,2),"g") plot(income(:,1),income(:,3),"b--") plot(income(:,1),income(:,4),"r-") title("US Income Inequality from 1913 to 2021") xlabel("Years") ylabel("Percentages of population") legend("Top 1%", "Top 10%", "Bottom 50%") subplot(2,1,2) hold on plot(wealth(:,1),wealth(:,2),"g") plot(wealth(:,1),wealth(:,3),"b--") plot(wealth(:,1),wealth(:,4),"r-") title("US Wealth Inequality from 1913 to 2021") xlabel("Years") ylabel("Percentages of population") legend("Top 1%", "Top 10%", "Bottom 50%") figure hold on plot(income(end-17:end,1),income(end-17:end,2),"g") plot(income(end-17:end,1),income(end-17:end,3),"b--") plot(income(end-17:end,1),income(end-17:end,4),"r-") title("US Income Inequality from 1913 to 2021") xlabel("Years") ylabel("Percentages of population") legend("Top 1%", "Top 10%", "Bottom 50%") %%maximum,minimum, and mean fprintf("The maximum of the bottom 50%% share of income over the years 1913 to 2021 is %.2f%%\n", max(income(:,4))*100); fprintf("The minimum of the bottom 50%% share of income over the years 1913 to 2021 is %.2f%%\n", min(income(:,4))*100); fprintf("The mean of the bottom 50%% share of income over the years 1913 to 2021 is %.2f%%\n", mean(income(:,4))*100)