filename='2315on5july.dat'; data=importdata(filename); %temperature data outside the enclosure on channel 2 data1=data(:,2); %temperature data inside the enclosure on channel 3 data2=data(:,3); %sampling frequency in Hz fs=100; [Txy,f] = tfestimate(data1,data2,[],[],[],fs); % finds a transfer function estimate when given an input signal and an output signal. newTxy=abs(Txy); %mag2db---20log10() newTxy1=mag2db(newTxy); fig1=figure %semilogx(f,newTxy) semilogx(f, newTxy, 'b','LineWidth', 2); grid on; title('Transfer Function', 'FontSize',16,'FontWeight','bold'); xlabel('Frequency in Hz', 'FontSize',16,'FontWeight','bold'); ylabel('Magnitude', 'FontSize',16,'FontWeight','bold'); print('fig1','transferfunc.pdf','-dpdf'); fig2=figure semilogx(f, newTxy1, 'r','LineWidth', 2); grid on; title('Transfer Function', 'FontSize',16,'FontWeight','bold'); xlabel('Frequency in Hz', 'FontSize',16,'FontWeight', 'bold'); ylabel('Magnitude in dB', 'FontSize',16,'FontWeight', 'bold'); print('fig2','transferfuncdB.pdf','-dpdf'); [Cxy,F] = mscohere(data1,data2,[],[],[],fs); %finds the magnitude-squared coherence estimate of the input signals using Welch's averaged modified periodogram method fig3=figure semilogx(F, Cxy, 'b','LineWidth', 2); grid on; title('Magnitude Squared Coherence', 'FontSize',16,'FontWeight','bold'); xlabel('Frequency in Hz', 'FontSize',16,'FontWeight','bold'); ylabel('Coherence', 'FontSize',16,'FontWeight','bold'); print('fig3','coherence.pdf','-dpdf');