Chirp plot is not drawing

1 次查看(过去 30 天)
Arkadius882
Arkadius882 2022-5-17
My chirp function is not being drawn for some reason, only stem samples are visible. If comment out stem command the plot is being drawn but to time 2e-3.
function fun6
tmax=4e-3;
T=2e-3;
fs=6e3;
xmax=2;
f1=0.5e3;
f2=1.5e3;
t=linspace(0,tmax,2001);
tt=mod(t,T);
x=xmax*chirp(tt,f1,T,f2);
n=fix(tmax*fs);
td=(0:n-1)/fs;
tdd=mod(td,T);
xd=xmax*chirp(tdd,f1,T,f2);
close all;
plot(tt,x,'b');
stem(td,xd,'r*');
grid on;zoom on;hold on;

回答(1 个)

Cris LaPierre
Cris LaPierre 2022-5-17
You need to place hold on before you add a second plot to your axes. Your code currently replaces the plot with the stem plot.
Your plot only goes to 2e-3 because that is what you define tt using mod. Perhaps you meant to use t when plotting?
tmax=4e-3;
T=2e-3;
fs=6e3;
xmax=2;
f1=0.5e3;
f2=1.5e3;
t=linspace(0,tmax,2001);
tt=mod(t,T);
x=xmax*chirp(tt,f1,T,f2);
n=fix(tmax*fs);
td=(0:n-1)/fs;
tdd=mod(td,T);
xd=xmax*chirp(tdd,f1,T,f2);
plot(t,x,'b'); % changed tt to t
hold on
stem(td,xd,'r*');
hold off

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by