Hello everybody! I'm currently attending a graduate econometric course and for a problem set I was asked to: - Build three vectors of arbitrary numbers, considering that: the first must contain a binary indicator (0-1) for gender, the second contains age, the third contains salary. Write these vectors in one Excel sheet - Import the Excel sheet in MATLAB as a matrix. - Using the functions for and if separate the matrix gender gap in two sub-matrixes: one with the earnings of men and the other with the earnings of women. - Plot the wage versus the age, using the plus sign (+) as marker style for the women, and a circle (0) as marker style for the men.
As far as the first two point, I haven't find any difficulties. However, when I'm asked to create the two sub-matrices what I was able to achieve are two matrices: one with the first column made of only zeros and the second column containing data for age and wages for woman; one with the first column made of ones, representing the mens.
This is the code I've written in Matlab:
A=xlsread('matrixA');
j=1;
k=1;
for i=1:size(A,1)
if A(i,1)==0
F(j,:) = A(i,:)
j = j+1;
else
M(k,:) = A(i,:)
k = k+1;
end
end
figure(1)
plot(F(:,2),F(:,3),'+',M(:,2),M(:,3),'ro')
xlabel('age')
ylabel('wage')
Said that, what I'm asking is: There's a way I can create the two sub-matricies without the two columns made of zeros and ones?