我是靠谱客的博主 秀丽酒窝,最近开发中收集的这篇文章主要介绍matlab for 循环写入表格问题和if有多个条件并在的问题(a>1&&b>2&&c>3) and so on,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
clear all;
clc;
close all;
r0=0.7;
r11=0.5;%Circulator coefficient1
r22=0.5;%Circulator coefficient2
t0=sqrt(1-r0^2);
r=0.8;
t=sqrt(1-r^2);
i=0;
j=1;
kk=[{char('r1')},{char('r2')},{char('r3')},{char('r4')},{char('T1')},{char('T2')},{char('T3')},{char('T4')},{char('phase1')},{char('phase2')},{char('phase3')},{char('phase4')},{char('wavelength')},{char('delay1')},{char('delay2')},{char('deta(delay1)')},{char('delay3')},{char('delay4')},{char('deta(delay3)')}];
xlswrite('dataInfo.xls',kk,'sheet1',['A',num2str(j)]);
stride=1e-12;
startpos=1546e-9;
endpos=1550e-9;
lam=startpos:stride:endpos;
% for r1=0.1
% for r2=0.1
% for r3=0.1
% for r4=0.1
for r1=0.1:0.1:0.9
for r2=0.5:0.1:0.9
for r3=0.1:0.1:0.9
for r4=0.1:0.1:0.9
i=i+1;
[i,r1,r2,r3,r4]
lambda=lam;
for m=1:length(lambda)
t1=sqrt(1-r1^2);
t2=sqrt(1-r2^2);
t3=sqrt(1-r3^2);
t4=sqrt(1-r4^2);
R=100e-6;
L1=0;L2=0;L3=0;L4=0;L5=0;L6=0;
k=0;
c=3e8;
f=c/lambda(m);
R=100e-6;
phase1=2*pi*R/lambda(m)*2*pi;
phase2=phase1;
a11=???;%%%%%%%%%%%%%%%%%%%%%
a22=???;%%%%%%%%%%%%%%%%%%%%%
b11=???;%%%%%%%%%%%%%%%%%%%%%
b22=???;%%%%%%%%%%%%%%%%%%%%%
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)
deta_p1(m)=ph11(m)-ph11(m-1);
deta_p2(m)=ph22(m)-ph22(m-1);
deta_p3(m)=ph33(m)-ph33(m-1);
deta_p4(m)=ph44(m)-ph44(m-1);
end
T1=abs(a111).^2+abs(b111).^2+abs(a222).^2+abs(b222).^2;
if max(abs(deta_p1))<0.8*pi && max(abs(deta_p2))<0.8*pi && max(abs(deta_p3))<0.8*pi && max(abs(deta_p4))<0.8*pi
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
[value1,pos1]=max(abs(delay1-delay2));
[value3,pos3]=max(abs(delay3-delay4));
if value1>=value3
mk=pos1;
else
mk=pos3;
end
value1=delay1(mk)*10^12;
value2=delay2(mk)*10^12;
value11=value1-value2;
value3=delay3(mk)*10^12;
value4=delay4(mk)*10^12;
value33=value3-value4;
wl_resonant1=startpos+(mk-1)*stride;
lambda=lam;
t1=sqrt(1-r1^2);
t2=sqrt(1-r2^2);
t3=sqrt(1-r3^2);
t4=sqrt(1-r4^2);
R=100e-6;
L1=0;L2=0;L3=0;L4=0;L5=0;L6=0;
k=0;
c=3e8;
f=c/wl_resonant1;
R=100e-6;
phase1=2*pi*R/wl_resonant1*2*pi;
phase2=phase1;
a11=???;%%%%%%%%%%%%%%%%%%%%%
a22=???;%%%%%%%%%%%%%%%%%%%%%
b11=???;%%%%%%%%%%%%%%%%%%%%%
b22=???;%%%%%%%%%%%%%%%%%%%%%
if abs(a11)^2>=0.25 && abs(b11)^2>=0.25 && abs(a22)^2>=0.25 && abs(b22)^2>=0.25
fid=fopen('data_mz.txt','a+');
fprintf(fid,'%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5ft%.5fn',r1,r2,r3,r4,T1(mk),T2(mk),T3(mk),T4(mk), ph11(mk), ph22(mk),ph33(mk),ph44(mk),wl_resonant1*10^6,value1,value2,value11,value3,value4,value33);
fclose(fid);
j=j+1;
xlswrite('dataInfo.xls',[r1,r2,r3,r4,T1(mk),T2(mk),T3(mk),T4(mk), ph11(mk), ph22(mk),ph33(mk),ph44(mk),wl_resonant1*10^6,value1,value2,value11,value3,value4,value33],'sheet1',['A',num2str(j)]);
end
plot(lambda,ph11)
hold on;
plot(lambda,ph22)
grid on
title('出口1相对于入口1,2的相位');
xlabel('lambda');ylabel('phase');
figure;
plot(lambda,delay1)
hold on;
plot(lambda,delay2)
grid on
title('出口1相对于入口1,2的时延');
xlabel('lambda');ylabel('delay');
figure;
plot(lambda,T1)
grid on
title('总透射量随波长的变化');
xlabel('lambda');ylabel('T');
end
end
end
end
end
最后
以上就是秀丽酒窝为你收集整理的matlab for 循环写入表格问题和if有多个条件并在的问题(a>1&&b>2&&c>3) and so on的全部内容,希望文章能够帮你解决matlab for 循环写入表格问题和if有多个条件并在的问题(a>1&&b>2&&c>3) and so on所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复