Chirp plot is not drawing

조회 수: 5 (최근 30일)
Arkadius882
Arkadius882 2022년 5월 17일
답변: Cris LaPierre 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에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by