% ### plotEAR.m ### 01.30.09 % code designed to take output of buildINFO.m (EARinfo.mat) and % extract/plot specified data clear load 'EARinfo.mat'; % plot size vs. weight if 1 == 1 for nn=1:size(A,2) % better way to extract structure data? % make sure entry is not empty (ignore via NaN's if so) if isempty(A(nn).massKG) || isempty(A(nn).BMlengthMM) mass(nn)= nan; BMlength(nn)= nan; else mass(nn)= A(nn).massKG; BMlength(nn)= A(nn).BMlengthMM; end end figure(6); clf; semilogx(mass, BMlength, 'ks') xlabel('Mass [kg]') ylabel('Basilar Membrane Length [mm]') title('Variation in Length of Sensory Organ w/ Respect to Body Mass') grid on; hold on; % do a linear fit to log(mass) % first exclude NaNs tempN= ~isnan(mass); massR= mass(tempN); BMlengthR= BMlength(tempN); a= polyfit(log(massR),BMlengthR,1); % plot fit mFIT= logspace(-2.2,5.5,100); plot(mFIT,(a(1)*log(mFIT) + a(2)),'r-'); % determine correlation coefficient x= log(massR); y= BMlengthR; N= size(x,2); varX= (1/N)* sum( (x-mean(x)).^2 ); % calculate the variance varY= (1/N)* sum( (y-mean(y)).^2 ); R= (1/N)* sum( ((x-mean(x)).*(y-mean(y)))./(sqrt(varX)*sqrt(varY)) ); disp(sprintf('correlation coefficent (R) for BM length re log(mass) is %g',R)); end % plot size vs. lower freq. limit if 1 == 0 for nn=1:size(A,2) % better way to extract structure data? % make sure entry is not empty (ignore via NaN's if so) if isempty(A(nn).massKG) || isempty(A(nn).freqRangeKHZ) mass(nn)= nan; freqH(nn)= nan; else mass(nn)= A(nn).massKG; %freqH(nn)= A(nn).freqRangeKHZ(2); % upper limit freqH(nn)= A(nn).freqRangeKHZ(1); % lower limit end end figure(7); clf; %semilogx(mass, freqH, 'ks') loglog(mass, freqH, 'ks') xlabel('Mass [kg]') ylabel('Hearing Lower Freq. Limit [kHz]') title('Variation in Upper Frequency Limit of Hearing w/ Respect to Body Mass') grid on; hold on; % % do a linear fit to log(mass) % % first exclude NaNs % tempN= ~isnan(mass); % massR= mass(tempN); % BMlengthR= BMlength(tempN); % a= polyfit(log(massR),BMlengthR,1); % % % plot fit % mFIT= logspace(-2.2,5.5,100); % plot(mFIT,(a(1)*log(mFIT) + a(2)),'r-'); end