MATLAB光计算微环模块代码保存

% MATLAB代码

clear all; clc; close all; tic r11=1/sqrt(2);%Circulator coefficient1 r22=1/sqrt(2);%Circulator coefficient2 tao=1;

L1=60e-6;L2=60e-6;
L3=60e-6;L4=60e-6;
L5=60e-6;L6=60e-6;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%定义文件路径和文件名%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dir_path='D:\文件\_%研究项目\光计算\F-P腔计算\qqq\LL_ogxl\figure';
save_path='D:\文件\_%研究项目\光计算\F-P腔计算\qqq\LL_ogxl\';
save_name= 'LL_';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%定义文件路径和文件名%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



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=30e-6;%LL1 LLK=30e-6;%LL2 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 ,save_name, num2str(i) , '.mat'] , 'A1');
        end
      end
    end
  end
end
toc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZhemgLee

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值