How to plot frequency error ?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Dynamic System Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!