Chirp plot is not drawing
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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;
0 comentarios
Respuestas (1)
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
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!