% Filename: MammalPulseRates.m
% M-file to
%    - enter mammal pulse rates data
%    - calc. correlation coeff. for y vs x
%    - calc. correlation coeff. for ln y vs x
%    - calc. correlation coeff. for ln y vs ln x

% Enter the data
x = [ 4
      25
      200
      300
      2000
      5000
      30000
      50000
      70000
      450000
      500000
      3000000 ]'; % body weight data
y = [ 660
      670
      420
      300
      205
      120
      85
      70
      72
      38
      40
      48 ]'; % pulse rate data

  
% Calculate correlation coeff. for y vs x
rho = corrcoef(x,y);
% Display the correlation coefficient
fprintf('(x,y)        rho = %f\n', rho(1,2))

% Calculate correlation coeff. for ln y vs x
rho = corrcoef(x,log(y));
% Display the correlation coefficient
fprintf('(x,ln y)     rho = %f\n', rho(1,2))

% Calculate correlation coeff. for ln y vs ln x
rho = corrcoef(log(x),log(y));
% Display the correlation coefficient
fprintf('(ln x, ln y) rho = %f\n', rho(1,2))