24小时热门版块排行榜    

查看: 5583  |  回复: 0

xpp8888

新虫 (初入文坛)

[求助] matlab中如何修改横轴坐标的问题

各位同仁:好!
我是新手,还不太会用小木虫,我现在想用matlab模拟光谱滤波,已经有了模拟光谱的程序,我需要在里面加一个透过率函数进行滤波,而这个透过率函数里面需要输入波长的值,它是一个变量,我原来模拟的光谱横轴不是波长,是以中心波长偏移的频率表示的,我现在想把它变成横轴用波长表示。然后再把波长带入透过率函数中得出透过的功率,重新画出光谱。下面是我原来的程序,希望高手给我指点应该怎么修改。
function OIFLD
% fencha of OF-LD with/without optical injection
    clc
    clear
   % clf
    syms t w;  
T1=clock;
  %激光器参数
    p.c=3*10^8;                %光子速度
    p.h=6.63*10^-34;           %普朗克常数
    p.q=1.6*10^-19;            %电荷所带电量
    p.dqe=0.266;               %全微分量子效应
    p.V=3.24*10^-16;           %active region volume 270*10*0.12 um*3 有源区体积
    p.Gn=5.89*10^-12;          %增益斜率
    p.af=5                  %线宽增强因子 4.9
    p.gm=1*10^-4;              %自发辐射因子
    p.eps=5*10^-23;            %增益饱和参量
    p.yt=0.24;                 %光场限制因子
    p.tn=2.5*10^-9;            %载流子寿命
    p.tl=7.38*10^-12;          %谐振腔的单次环行时间
    p.tp=1.17*10^-12;          %光子寿命
    p.n0=0.455*10^24;          %透明载流子密度
    p.nt=1.06*10^24;           %阈值载流子密度
    p.nsp=2.7;
    % 控制项1--电流--            
    ith=0.022;   %阈值电流
        % bias of slave, master,and injection laser
             Is=3.88*ith;  %slave偏置电流
            Im=3.88*ith;   %master偏置电流
           
            R2=0.3;      %端面反射率
    % OI strength, detuning and time-point   光注入的强度、失谐量、时间点
            p.km=0.09;  %注入系数  
            
            p.vs=p.c/(1.55*10^-6);  %从激光器的频率
            p.dvm=6*10^9;    % p.dvm=p.vm-p.vs 失谐量
            
            p.ti=5*10^-9;   %时间点
% OF strength,time-point and delay.  光反馈的强度,时间点,延迟
            
            p.kf=0.011;% 反馈系数7

            p.tf=3*10^-9;    %时间点
            p.tlag=20*10^-9;  %延迟时间
            
            
            x0=[1.06*10^24;9.10*10^9;100];  %初始条件
            
            ts=0; tfm=31*10^-9;tfs=30*10^-9;%for OI tfm=35ns, tfs=30ns, analyzes last 20ns data
                                                %for OI tfm=75ns, tfs=70ns,analyzes last 20ns data
        %_____________________________________________________________
       mstep=2*10^-12;            
            opt1=odeset('RelTol',1e-5,'AbsTol',1e-8,'MaxStep',mstep); %设微分方程的参数,解得条件 RelTol相对误差,默认值为1e-5 , AbsTol绝对误差,默认值为1e-8 maxstep此参数是限定算法能使用的区间长度上限的标量
            solm=ode45(@master,[ts,tfm],x0,opt1,p,Im);   %解微分方程,中等精度,使用Runge-Kutta法的四五阶算法。
            
            opt2=ddeset('RelTol',1e-5,'AbsTol',1e-8,'MaxStep',mstep,'InitialY',x0,'Jumps',[p.ti,p.tf]);%常微分方程DDE的数值求解器的设置
            sols=dde23(@OIFRQ,p.tlag,[0,0,0],[ts,tfs],opt2,p,Is,solm);  %解常微分方程
            
        fs=50*10^9;    %采样时间
            t=tfs/10:1/fs:tfs;
                    %***********************************
                    [ys,yps]=deval(sols,t);
                  
                    t=t*10^9;                           % time /ns changing unit for figure display
                    %Ns=ys(1,/p.nt;                    % nomalized carrier density by its threshold
                    Ss=ys(2,.^2;                         % photon density 光子强度
                    %pha=ys(3,;       % phase of laser in 2*pi range
                    %dvs=yps(3,*10^-9/(2*pi);           % optical frequency chirp of slave laser /GHz
                    
                    Ps=1000*p.dqe*p.V*p.h*p.vs*Ss/(2*p.yt*p.tp);% output power /mW  从激光器的输出功率
                    Ps=Ps*0.01
                    P=Ps-mean(Ps);   %求均值
[ft,pws]=spectrum(fs,P);  %这个是调用 spectrum文件中的函数 那个函数的描述是这样的input y is in mW , and output pw in dBm,好像里面做了一些运算
                  
           %figure(1) % phase space  画图
            % l=length(Ps);  n=fs*10^-9;  % 1ns delay   
            % plot(Ps(1:l-n),Ps(n+1:l))
           %figure(2)
                   %subplot(2,1,1),
                  %plot(t,Ps)
           %       xlabel('t [ns]');ylabel('P [mW]');v
                   %subplot(2,1,2),plot(t,dvs)
                   %xlabel('t [ns]');ylabel('dφ/dt [GHz]');
                           
           figure(3)  
            [N,BW]=simBWchaos(ft,pws)  %调用simBWchaos函数 ,那个函数的描述是calculting bandwidth of chaos,which is defined as the span between the DC and
            % the frequency where 80% of the energy is contained within.
            % 计算混沌波的带宽%……¥……%¥……%%……
            
           %figure(4)
           % [c,lag]=xcorr(P,P,'coeff'); %xcorr 是自相关函数,自相关函数是描述随机信号X(t)在任意两个不同时刻t1,t2的取值之间的相关程度,
            %lag=lag*10^9/fs;
           % plot(lag,c)
            
            fs=1*10^12;
                   tt=8*tfs/10:1/fs:tfs;
                    %***********************************
                   [ys,yps]=deval(sols,tt);
                  Ss=ys(2,.^2;
                   P=p.dqe*p.V*p.h*p.vs*Ss/(2*p.yt*p.tp);       %光功率 W
                  vs=50*10^9;
                  es=sqrt(P).*exp(j*(2*pi*vs*tt+ys(3,));        %光复振幅               
                [color=]  neff=1.47;
                  lamda=1.55*10^-6;                        
                  thetar=pi/4;               
                  theta2=pi/4;
                  theta1=pi/4;
                  detaL=6.00547*10^-3;
                  Lr=2*detaL+lamda/2;              
                  alpha=0.1;               
                  k=exp(-alpha*Lr);               
                  fair=2*pi*neff*Lr/lamda;               
                  T=[cos(thetar)-k*exp(-j*fair)]/[1-cos(thetar)*k*exp(-j*fair)];                    
                  
                  detaq=2*pi*neff*detaL/lamda;
                  es1=es.*[T*cos(theta2)*cos(theta1)-sin(theta2)*sin(theta1)*exp(-j*detaq)];[/color】
                 [fes,ews]=ospect(fs,es)
                  
                  [fes,ews1]=ospect(fs,es1);
                  p=es1.*conj(es1);
                  [ft,pws1]=spectrum(fs,p);
                  
                    
             figure(5)  
            [N,BW]=simBWchaos(ft,pws1)
                 
             figure(6)
                   fes=(fes-vs)*10^-9;
                  plot(fes,ews,'black','LineWidth',1.3)
                  %set(gca,'XLim',[-50 50]);
                  xlabel('frequency(ghz)');ylabel('power dBm');
            figure(7)
                   fes=(fes-vs)*10^9;
                  plot(fes,ews1,'black','LineWidth',1.3)
                  %set(gca,'XLim',[-50 50]);
                  xlabel('frequency(ghz)');ylabel('power dBm');
            
               
            save ch t Ps N BW ft pws c lag fes ews
fprintf('\n');
    fprintf('\t');
    fprintf('CPUTIME IS');
    lll=etime(clock,T1);
    disp(lll);        
红颜色的部分是我的透过率函数,里面光谱画图部分的程序以VS作为一个任意值来画横轴的,不知怎么修改还请指教!
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 xpp8888 的主题更新
信息提示
请填处理意见