[問題] 波德圖已回收

看板MATLAB作者 (~黑妞~)時間15年前 (2010/10/22 11:32), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
因為實驗的需要 想利用輸入與輸出訊號畫出系統的波德圖 我自己的想法是利用swept sin訊號輸入系統 將得到的輸入輸出訊號分別轉成頻域 根據頻率響應的定義得到大小圖與相位圖 ======================================== 為了驗證此方法可以畫出波德圖 我先自己假設一系統,並且輸入swept sin 利用bode指令與自己的方法比較 比較後有兩個主要的問題出現 1.當系統為Type0時,大小圖一致,可是相位圖在高頻時有誤差 2.當系統為Type1時,兩圖的誤差都很大 以下附上程式碼 ======================================== clc;clear;close all line=1.5; %% VDHM model Ka=55/3;%cc/volt Ps=140;%bar Kt=1.59*140/100;%torque constant Jm=0.065; Bm=0.04; ts=0.005; Gps=tf([0 Ka*Kt],[Jm Bm]); Gpz=c2d(Gps,ts); [As Bs Cs Ds]=ssdata(Gps); [Az Bz Cz Dz]=c2dm(As,Bs,Cs,Ds,ts,'z'); xz=[0]; %% frequency analysis tf=60; Hz=1/ts;%取樣頻率 N=Hz*tf;%資料數 NHz=Hz-1/N; f=(0:Hz/N:Hz-Hz/N); xchirp=[0]; tsin=[0:ts:tf]; f0=0.01;f1=30; usin=chirp(tsin,f0,tf,f1,'logarithmic'); f_final=30;%Hz for i=1:tf/ts tchirp(i)=(i-1)*ts; uchirp(i)=usin(i); xchirp=Az*xchirp+Bz*uchirp(i); ychirp(i)=Cz*xchirp+Dz*uchirp(i); end figure(1) subplot(211) plot(tchirp,uchirp,'linewidth',line) xlabel('sample number');ylabel('volt'); title('chirp sin signal');box on; axis([0 tf min(uchirp)*1.5 max(uchirp)*1.5]) subplot(212) plot(tchirp,ychirp,'linewidth',line) xlabel('time(s)');ylabel('degree/s'); title('chirp sin response of VDHM');box on; axis([0 tf min(ychirp)*1.2 max(ychirp)*1.2]) uchirp_f=fft(uchirp,tf/ts); ychirp_f=fft(ychirp,tf/ts); uchirp_mag=abs(uchirp_f); ychirp_mag=abs(ychirp_f); %由頻率響應定義(輸入訊號要為sin)可得下列mag和phase程式運算式 mag=20*log10(ychirp_mag./uchirp_mag);%db phase=angle(ychirp_f./uchirp_f)*180/pi;%degree w_rad=logspace(-1,3,N); [mGps,pGps]=bode(Gps,w_rad); figure(2) subplot(211) semilogx(w_rad/2/pi,20*log10(squeeze(mGps)),'r',f,mag,'linewidth',line) title('magnitude');legend('by bode','fft') axis([Hz/N f1 1.2*min(mag) 1.2*max(mag)]); xlabel('frequency(Hz)');ylabel('mag(db)'); grid on;box on; subplot(212) semilogx(w_rad/2/pi,squeeze(pGps),'r',f,phase,'linewidth',line) title('phase');legend('by bode','fft') axis([Hz/N f1 1.2*min(phase) 0]); xlabel('frequency(Hz)');ylabel('phase(degree)'); grid on;box on; 想請教板上的各位~為什麼會有這樣的現象出現 或是matlab有內建的指令可以直接根據輸入與輸出畫出波德圖 -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.155.231

10/23 18:37, , 1F
建議你看一下"數值分析"
10/23 18:37, 1F
文章代碼(AID): #1CmGNdx_ (MATLAB)
文章代碼(AID): #1CmGNdx_ (MATLAB)