フィルターのクリア

Chirp plot is not drawing

2 ビュー (過去 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 Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by