e893.m

来自「matlab算法集 matlab算法集」· M 代码 · 共 50 行

M
50
字号
%-----------------------------------------------------------------------
% Example 8.9.3: Phase-Locked Loop 
%-----------------------------------------------------------------------

% Initialize

   clc                          % clear screen
   clear                        % clear variables
   global wc w0 alpha           % used by funu893.m, funp893.m 
   wc    = 2*pi*1000;           % PLL center frequency (rad/s) */
   m     = 1000;                % solution points
   n     = 2;                   % dimension of system 
   t1    = 0.025;               % final time 
   tol   = 1.e-6;               % error bound 
   q     = 40000;               % maximum function evaluations
   t     = zeros (m,1);         % solution points 
   u     = zeros (m,1);         % input samples  
   y     = zeros (m,1);         % output samples 
   v     = zeros (m,1);         % feedback signal 
   x0    = [0 0]';              % initial state 
   w0    = 2*pi*1050;           % input frequency 
   alpha = 1600;
    
% Solve equations 

   fprintf ('Example 8.9.3: Phase-Locked Loop\n');
   [t,X,e,k] = rkf (x0,0,t1,m,tol,q,'funp893');

% Compute input and output 
   
   for i = 1 : m
      u(i) = funu893 (t(i));
      y(i) = (X(i,1) + wc)/(2*pi);
      v(i) = cos(X(i,2));
   end

% Display results    
   
   t = 1000*t;
   show ('Number of scalar function evaluations',k);   
   show ('Maximum truncation error',e);
   show ('Final estimate of frequency (Hz)',y(m));
   graphxy (u,v,'Oscillator','u','v')
   graphxy (t,y,'PLL Output','t (msec)','y (Hz)')
%-----------------------------------------------------------------------



   

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?