Chirp plot is not drawing

1 visualización (últimos 30 días)
Arkadius882
Arkadius882 el 17 de Mayo de 2022
Respondida: Cris LaPierre el 17 de Mayo de 2022
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;

Respuestas (1)

Cris LaPierre
Cris LaPierre el 17 de Mayo de 2022
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

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by