程序如下
hf=figure('Position',[200 200 600 400],'Name','光纤通信实验','NumberTitle','off');
global P0 F0 f0 df dF dT
uicontrol(hf,'style','text','units','pixels','string','光信号平均功率','position',[100 300 80 20]);
Num1=uicontrol(hf,'style','edit','units','pixels','string','100','position',[220 300 50 20],'callback','NumStr=get(Num1,''String'') P0=str2num(NumStr)'); %
uicontrol(hf,'style','text','units','pixels','string','光载波频率','position',[100 250 80 20]);
Num2=uicontrol(hf,'style','edit','units','pixels','string','1000','position',[220 250 50 20],'callback','NumStr=get(Num2,''String'') F0=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','初始相位','position',[100 200 80 20]);
Num3=uicontrol(hf,'style','edit','units','pixels','string','0.8','position',[220 200 50 20],'callback','NumStr=get(Num3,''String'') f0=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','相位噪声差值','position',[100 150 80 20]);
Num4=uicontrol(hf,'style','edit','units','pixels','string','1','position',[220 150 50 20],'callback','NumStr=get(Num4,''String'') df=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','激光器线宽','position',[100 100 80 20]);
Num5=uicontrol(hf,'style','edit','units','pixels','string','10','position',[220 100 50 20],'callback','NumStr=get(Num5,''String'') dF=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','连续间隔','position',[100 350 80 20]);
Num6=uicontrol(hf,'style','edit','units','pixels','string','10','position',[220 350 50 20],'callback','NumStr=get(Num6,''String'') fprintf(''%s'',NumStr); dT=str2num(NumStr)');%
func=uicontrol(hf,'style','pushbutton','string','确定','position',[220 50 50 20],'callback','simulate(P0,F0,f0,df,dF,dT)');
%fprintf('%f %f %f %f %f %f',P0,F0,f0,df,dF,dT);
hf=figure('Position',[200 200 600 400],'Name','光纤通信实验','NumberTitle','off');
global P0 F0 f0 df dF dT
uicontrol(hf,'style','text','units','pixels','string','光信号平均功率','position',[100 300 80 20]);
Num1=uicontrol(hf,'style','edit','units','pixels','string','100','position',[220 300 50 20],'callback','NumStr=get(Num1,''String'') P0=str2num(NumStr)'); %
uicontrol(hf,'style','text','units','pixels','string','光载波频率','position',[100 250 80 20]);
Num2=uicontrol(hf,'style','edit','units','pixels','string','1000','position',[220 250 50 20],'callback','NumStr=get(Num2,''String'') F0=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','初始相位','position',[100 200 80 20]);
Num3=uicontrol(hf,'style','edit','units','pixels','string','0.8','position',[220 200 50 20],'callback','NumStr=get(Num3,''String'') f0=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','相位噪声差值','position',[100 150 80 20]);
Num4=uicontrol(hf,'style','edit','units','pixels','string','1','position',[220 150 50 20],'callback','NumStr=get(Num4,''String'') df=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','激光器线宽','position',[100 100 80 20]);
Num5=uicontrol(hf,'style','edit','units','pixels','string','10','position',[220 100 50 20],'callback','NumStr=get(Num5,''String'') dF=str2num(NumStr)');%
uicontrol(hf,'style','text','units','pixels','string','连续间隔','position',[100 350 80 20]);
Num6=uicontrol(hf,'style','edit','units','pixels','string','10','position',[220 350 50 20],'callback','NumStr=get(Num6,''String'') fprintf(''%s'',NumStr); dT=str2num(NumStr)');%
func=uicontrol(hf,'style','pushbutton','string','确定','position',[220 50 50 20],'callback','simulate(P0,F0,f0,df,dF,dT)');
%fprintf('%f %f %f %f %f %f',P0,F0,f0,df,dF,dT);