⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fourierdecold.m

📁 关于电机的.m程序
💻 M
字号:
%Fourierdec.m ==> Fourier series decomposition of periodic functions of identical periods 
% specify the column vector t and array f representing the signals over one complete period
% for an illustration, run fourier0.m
clc,close all
disp(date)
disp('fundamental frequency (Hz)')
T=t(length(t));
fo=round(1/T);
disp(fo)
nu=0;
%%%
for w=1:size(f,2);
   nu=nu+1;
   disp(['   Function No. ' num2str(nu)]);
   disp('_________________________________')
   disp('   order of | amplitude |  phase')
   disp('   harmonic |           |  [deg]')
   disp('____________|___________|________')
  
   g=f(:,w);
%%% Complex Fourier coefficients ck
       co=1/T*trapz(t,g)+eps;             
       fprintf('%8.0f%13.4f\n',0,co)
       C=[];
     for k=[1:h]
        q=g.*exp(-j*2*pi/T*t*k);  
        ck= 2/T*abs(trapz(t,q));
        pk=angle(trapz(t,q))*180/pi;
        C=[C ck];
        fprintf('%8.0f%13.4f%11.2f\n',k,ck,pk)
     end
     disp('================================')
    %%%  Plots 
   order=((1:h+1)-1)'; mag=[co C]';    
  figure('Position',[225 70 760 555],'Name','Fourier analysis');
   %figure(n)  
   subplot(2,1,1),plot([0 T],[0 0],'k',t,g,'r','linewidth',2),grid
   xlabel('TIME [s]') ;ylabel('SIGNAL');
   title('PERIODIC SIGNAL')
   subplot(2,1,2),stem(order,mag,'-ob')
   xlabel('HARMONIC ORDER'); ylabel('AMPLITUDE');
   title('FOURIER COMPONENTS'),grid
end

⌨️ 快捷键说明

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