%% Planks Constant % hf/e-Wo/e=Vo close all; clear all; clc Lambda=[578,546.074,435.835,404.656,365.483]; Freq=3*10^8./Lambda; %% Decay Time PercentTrans=[100,80,60,40,20]; Decay1Y=[6.06,9.13,12.21,16.75,26.97]; Decay2Y=[6.34,9.22,13.28,14.88,26.09]; Decay3Y=[6.83,9.44,11.09,15.88,29.96]; Decay1G=[14.16,17.75,30.07,35.41,53.28]; Decay2G=[13.59,18.34,27.88,35.34,61.47]; Decay3G=[14.78,19.31,29.59,34.88,58.12]; plot(PercentTrans,Decay1Y,'x',PercentTrans,Decay2Y,'x',PercentTrans,... Decay3Y,'x'); set(gcf,'color',[1,1,1]); xlabel('Percent Transmission'); ylabel('Charge Time'); title('Yellow emission') %axis([10 110 max([Decay1Y,Decay2Y,Decay3Y]) min([Decay1Y,Decay2Y,Decay3Y])) figure plot(PercentTrans,Decay1G,'x',PercentTrans,Decay2G,'x',PercentTrans,... Decay3G,'x'); set(gcf,'color',[1,1,1]); xlabel('Percent Transmission'); ylabel('Charge Time'); title('Green Emission') %axis([10 110 max([Decay1G,Decay2G,Decay3G]) min([Decay1G,Decay2G,Decay3G])) %% First Order VT1FO=[.717,.847,1.502,1.725,2.077]; VT2FO=[.714,.853,1.500,1.751,2.078]; VT3FO=[.719,.857,1.510,1.735,2.075]; %trial 1 slope calculations Freqsmooth=linspace(0,Freq(end),100); polyfo=polyfit(Freq,VT1FO,1); lsrfo=polyval(polyfo,Freqsmooth); Wo1=polyfo(2) slope1=polyfo(1) %trial 1 slope calculations polyfo2=polyfit(Freq,VT2FO,1); lsrfo2=polyval(polyfo,Freqsmooth); Wo2=polyfo2(2) slope2=polyfo2(1) %trial3 slope calculations NEW polyfo3=polyfit(Freq,VT3FO,1); lsrfo3=polyval(polyfo,Freqsmooth); Wo3=polyfo2(2) slope3=polyfo2(1) %actual slope: slopeact=4.141249*10^-6; lsract=polyval([slopeact,-1.369],Freqsmooth); %plots plot(Freq,VT1FO,'x',Freq,VT2FO,'rx',Freq,VT3FO,'x',Freqsmooth,lsrfo,... Freqsmooth,lsrfo2,Freqsmooth,lsrfo3,'k',Freqsmooth,lsract) xlabel('frequency (Hz)');ylabel('Vo (V)'); set(gcf,'color',[1,1,1]);title('first order') legend('Trial 1', 'Trial 2', 'Least Squares','Actual Slope'); %plots2 figure plot(Freq,VT3FO,'x',Freqsmooth,lsrfo3,'k',Freqsmooth,lsract) xlabel('frequency (Hz)');ylabel('Vo (V)'); set(gcf,'color',[1,1,1]);title('first order') legend('Trial3','LSR','Actual'); %% MEANS AND ERROR BARS SEMFO=1/sqrt(3)*[std([VT1FO(1),VT2FO(1),VT3FO(1)]),... std([VT1FO(2),VT2FO(2),VT3FO(2)]),... std([VT1FO(3),VT2FO(3),VT3FO(3)]),... std([VT1FO(4),VT2FO(4),VT3FO(4)]),... std([VT1FO(5),VT2FO(5),VT3FO(5)])] MEANFO=[mean([VT1FO(1),VT2FO(1),VT3FO(1)]),... mean([VT1FO(2),VT2FO(2),VT3FO(2)]),... mean([VT1FO(3),VT2FO(3),VT3FO(3)]),... mean([VT1FO(4),VT2FO(4),VT3FO(4)]),... mean([VT1FO(5),VT2FO(5),VT3FO(5)])] %multiplicative MEANFOCorrection=-linspace(0,.1312,5) %MEANFO=MEANFO+MEANFOCorrection %calculation of lsr fit polyfomean=polyfit(Freq,MEANFO,1); polyfomean2=polyfomean+[-.00000009,.05] %slope correction by inspection lsrfomean=polyval(polyfomean,Freqsmooth); lsrfomean2=polyval(polyfomean2,Freqsmooth); %slope correction by inspection Womean=polyfomean(2) slopemean=polyfomean(1) hmean=slopemean*1.6 hmean2=polyfomean2(1)*1.6 Womean2=polyfomean2(2) %error bars and plots plot(Freqsmooth,lsract,'--',Freqsmooth,lsrfomean,'r',... Freqsmooth,lsrfomean2,'g'); xlabel('Frequency (10^9/s)');ylabel('Voltage (V)'); set(gcf,'color',[1,1,1]);title('First Order Fringes') legend('Accepted', 'Mean Least Squres','Modified Least Squares'); hold on errorbar(Freq,MEANFO,SEMFO,'ko');hold off %% Second Order VT1SO=[.731,1.269,1.519,1.730,2.071]; VT2SO=[.738,1.274,1.520,1.729,2.067]; %trial 1 slope calculations Freqsmooth=linspace(Freq(1),Freq(end),100); polyfo=polyfit(Freq,VT1SO,1); lsrfo=polyval(polyfo,Freqsmooth); Wo12=polyfo(2) slope12=polyfo(1) %trial 1 slope calculations polyfo2=polyfit(Freq,VT2SO,1); lsrfo2=polyval(polyfo,Freqsmooth); Wo2=polyfo2(2) slope2=polyfo2(1) %plots figure plot(Freq,VT1SO,'x',Freq,VT2SO,'rx',Freqsmooth,lsrfo,... Freqsmooth,lsrfo2,Freqsmooth,lsract) xlabel('frequency (Hz)');ylabel('Vo (V)'); set(gcf,'color',[1,1,1]);title('second order'); legend('Trial 1', 'Trial 2', 'Least Squares','Actual Slope'); %% First Order h calculations