% Ryan E. Freling % Econometrics II % Fall 2010 % Assignment 1 clc clear %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Load datayx.csv %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% load datayx.csv; y=datayx(:,1); x=datayx(:,2); n=size(datayx,1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % A. Sort X from smallest to largest %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xsort=x; t=0; for j=1:n; for i=1:n-1; if xsort(i,1)>xsort(i+1,1); t=xsort(i,1); xsort(i,1)=xsort(i+1,1); xsort(i+1,1)=t; t=0; end; end; end; disp('Sorted Values of X (ascending)'); xsort % test result of sort program z=sort(x); [xsort-z]; % test result of sort program zx=[xsort-z]; disp('Test result of sort program') disp(' ') disp('If sumtest=0, sort program matches MATLAB'); sumtest=sum(zx) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % B. Sort Y from largest to smallest %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ysort=y; t=0; for j=1:n; for i=1:n-1; if ysort(i,1)