% M-FILE TO COMPUTE EIGENVALUES, EIGENVECTORS AND
% THE ROSSBY RADII OF DEFORMATION OF A STEPWISE
% DENSITY PROFILE.
%
f=input('Give f: \n');
dp=input('Give the thicknesses of the layers (in m) \n (include the values in brackets, ex. [100 200 1000]): \n');
sg=input('Give the sigmas of the layers (in kg/m^3) \n (include the values in brackets, ex. [23.1 25 27.5]): \n');
m=length(dp);
for i=1:m
for j=1:i
M(i,j)=sqrt(dp(i)*dp(j))/(1+max(sg(i),sg(j))*1e-3);
M(j,i)=M(i,j);
end
end
[vect,e]=eig(M);
eigv=diag(e);
for i=1:m
for j=1:m
a(j)=sign(vect(1,j));
evec(i,j)=1e4*vect(i,j)/(a(j)*sqrt(dp(i)));
end
end
rad=1e-3*sqrt(9.81*eigv)/f;
str1=num2str(fliplr(eigv'));
str2=num2str(fliplr(rad'));
str3=num2str(fliplr(evec));
disp(' ')
disp('-------------------RESULTS--------------------')
disp('-------in ascending order (n=0,1,2,...)-------')
disp(' ')
disp('Eigenvalues (equivalent depths):')
disp(' ')
disp(str1)
disp(' ')
disp('Rossby Radii of Deformation (km):')
disp(' ')
disp(str2)
disp(' ')
disp('Eigenvectors (Velocity Profiles in cm/s):')
disp(' ')
disp(str3)
