MATLAB光計算微環模組程式碼儲存
阿新 • • 發佈:2020-12-01
% MATLAB程式碼
clear all; clc; close all; tic r11=1/sqrt(2);%Circulator coefficient1 r22=1/sqrt(2);%Circulator coefficient2 tao=1; dir_path='D:\檔案\_%研究專案\光計算\F-P腔計算\qqq\LL_ogxl\figure'; save_path='D:\檔案\_%研究專案\光計算\F-P腔計算\qqq\LL_ogxl\'; stride=6e-12; startpos=1520e-9; endpos=1560e-9; lam=startpos:stride:endpos;% a11=0;a22=0;b11=0;b22=0; i=0; for LL=[27e-6,29e-6,31e-6,33e-6] for r0=[sqrt(0.15)] for r=[sqrt(0.15)] for r1=[sqrt(0.15)] for r3=[sqrt(0.15)] i=i+1; % LL=10e-6;%LL1 LLK=30e-6;%LL2 L1=60e-6;L2=60e-6; L3=60e-6;L4=60e-6; L5=60e-6;L6=60e-6; L7=LL/2;L8=LL-L7; L9=LL/2;L0=LL-L9; LL1=LLK/2;LL2=LLK-LL1; LL3=LLK/2;LL4=LLK-LL3; r2=sqrt(1-r1^2); r4=sqrt(1-r3^2); % r2=r1; % r4=r3; t0=sqrt(1-r0^2); t=sqrt(1-r^2); t1=sqrt(1-r1^2); t2=sqrt(1-r2^2); t3=sqrt(1-r3^2); t4=sqrt(1-r4^2); lambda=lam; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%定義關鍵字%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% key_word = 'LL='; key_value = num2str(LL); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%定義關鍵字%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for m=1:length(lambda) c=3e8; f=c/lambda(m); k=2*pi/lambda(m); %下面涉及研究內容的具體公式,這裡省略不寫 a11=1; a22=2; b11=3; b22=4; %上面涉及研究內容的具體公式,這裡省略不寫 a111(m)=a11; a222(m)=a22; b111(m)=b11; b222(m)=b22; T1(m)=abs(a11)^2; T2(m)=abs(b11)^2; T3(m)=abs(a22)^2; T4(m)=abs(b22)^2; ph11(m)=angle(a11); ph22(m)=angle(b11); ph33(m)=angle(a22); ph44(m)=angle(b22); end ph11=unwrap(ph11); ph22=unwrap(ph22); ph33=unwrap(ph33); ph44=unwrap(ph44); for m=2:length(lambda) delay1(m)=-((ph11(m)-ph11(m-1))/(lambda(m)-lambda(m-1)))*(lambda(m)^2)/2/pi/c; delay2(m)=-((ph22(m)-ph22(m-1))/(lambda(m)-lambda(m-1)))*(lambda(m)^2)/2/pi/c; delay3(m)=-((ph33(m)-ph33(m-1))/(lambda(m)-lambda(m-1)))*(lambda(m)^2)/2/pi/c; delay4(m)=-((ph44(m)-ph44(m-1))/(lambda(m)-lambda(m-1)))*(lambda(m)^2)/2/pi/c; end h1=figure; plot(lambda,delay1,'r') hold on; plot(lambda,delay2,'b') grid on xlabel('lambda');ylabel('delay'); hold on; hold on; plot(lambda,delay2-delay1,'k') legend('Delay1','Delay2','ΔDelay1') title([key_word,key_value,' '],'fontsize',15); name1=[dir_path,num2str(i),'1','.jpg']; name2=[dir_path,num2str(i),'1','.fig']; saveas(h1,name1); saveas(h1,name2); h2=figure; plot(lambda,abs(a111).^2,'r') hold on; plot(lambda,abs(b111).^2,'b') hold on; grid on legend('a1','b1') xlabel('lambda');ylabel('T'); title([key_word,key_value,' '],'fontsize',15); name1=[dir_path,num2str(i),'2','.jpg']; name2=[dir_path,num2str(i),'2','.fig']; saveas(h2,name1); saveas(h2,name2); h3=figure; plot(lambda,delay3,'r') hold on; plot(lambda,delay4,'b') grid on xlabel('lambda');ylabel('delay'); hold on; hold on; plot(lambda,delay3-delay4,'k') title([key_word,key_value,' '],'fontsize',15); legend('Delay3','Delay4','ΔDelay3') name1=[dir_path,num2str(i),'3','.jpg']; name2=[dir_path,num2str(i),'3','.fig']; saveas(h3,name1); saveas(h3,name2); h4=figure; plot(lambda,abs(a222).^2,'r') hold on; plot(lambda,abs(b222).^2,'b') hold on; grid on legend('a2','b2') title([key_word,key_value,' '],'fontsize',15); xlabel('lambda');ylabel('T'); name1=[dir_path,num2str(i),'4','.jpg']; name2=[dir_path,num2str(i),'4','.fig']; saveas(h4,name1); saveas(h4,name2); h5=figure; plot(lambda,delay2-delay1,'r') hold on; plot(lambda,delay3-delay4,'b') legend('ΔDelay1','ΔDelay3'); grid on xlabel('lambda');ylabel('Δdelay'); title([key_word,key_value,' '],'fontsize',15); name1=[dir_path,num2str(i),'5','.jpg']; name2=[dir_path,num2str(i),'5','.fig']; saveas(h5,name1); saveas(h5,name2); close all A1=cell(5,4); A1{1,1}=a111';A1{1,2}=b111';A1{1,3}=a222';A1{1,4}=b222'; A1{2,1}=T1';A1{2,2}=T2';A1{2,3}=T3';A1{2,4}=T4'; A1{3,1}=ph11';A1{3,2}=ph22';A1{3,3}=ph33';A1{3,4}=ph44'; A1{4,1}=delay1';A1{4,2}=delay2';A1{4,3}=delay3;A1{4,4}=delay4'; % save A1 save([save_path , 'A' , num2str(i) , '.mat'] , 'A1'); end end end end end toc