필터 지우기
필터 지우기

How to plot frequency error ?

조회 수: 1 (최근 30일)
Aniket
Aniket 2013년 2월 7일
I am giving input signal as a chirp with time varying frequencies. i want to plot frequency error of input signal frequency and frequency adapted by oscillator. how should i do it ? please suggest me.
here is code ......
************************
Fs=1000; % sample rate
tf=50; % 2 seconds
t=0:1/Fs:tf-1/Fs;
f1=100;
f2=200; % start @ 100 Hz, go up to 200Hz
semi_t=0:1/Fs:(tf/2-1/Fs);
sl=2*(f2-f1/2);
f1=f1*semi_t+(sl.*semi_t/50);
f2=f1(end)+f2*semi_t-sl.*semi_t/2;
f=[f1 f2];
y=1.33*cos(2*pi*f.*t);
ti = tt ;
[T Y]= ode45(@(t,y) myeqd(t,y,ti,xx),tt,[5;5;90]);
plot (T,Y)
***********************
the ode function
*************************
function dz = myeqd(t,y,ti,xx)
dz = zeros(3,1);
mu=1;
r= sqrt(y(1)^2 + y(2)^2);
K=1000;
F=interp1(ti,xx,t);
dz(1)= (mu - r^2)*y(1) - y(3)*y(2) +K*F;
dz(2) = (mu - r^2)*y(2) + y(3)*y(1);
dz(3) = (-K*F) * (y(2)/sqrt(y(1)^2 + y(2)^2));
********************************************

답변 (0개)

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by