function [dP min1 min2] = Sub_P(S,numfreq)
% This function will calculate the determinants of the P matrix, the first
% principal minor, and the second principal minor for each frequency.
% You will need to fill in the rest of the code inside the for loop to
% calculate the determinants of the P matrix, where P = U - s'*s, the first
% principal minor, and the second principal minor.
% U is the 2x2 identity matrix, which can be created with the eye function
% use the det function to calculate the determinant
dP = zeros(numfreq,1); % memory allocation for det of dissipation matrix
min1 = zeros(numfreq,1); % memory allocation for first prin minor
min2 = zeros(numfreq,1); % memory allocation for second prin minor
for i = 1:1:numfreq % loop calculates desired values for each frequency point
s = S(:,:,i); % the S matrix [S11,S12;S21,S22] for the ith frequency
% here you will write the rest of the code to calculate the P
% matrix and the appropriate determinants
% remember that the i,j minor is calculated by the removing the ith
% row and the jth column of the matrix
% a principal minor is one where i = j
% think about which value remains when you take the 1st or 2nd
% principal minor of a 2x2 matrix
% after you have calculated the correct values for each, you will
% have to put them in the correct array cell in the right variable
% e.g. dP(i) = detP; where detP is the value you calculated for the
% determinant of P
end
end