Adjusting a Sawtooth Graph and getting spectrum

I am trying to graph a traingle wave with a width of 8000pi (4000pi each way from 0) and get its spectrum. This is what I have but can't get figure 1 to look right. I am unsure what I am doing wrong, my best guess would be I need to change either T or the first variable in sawtooth but doing that keeps making it worse so I'm not sure. Thank you for your time!
T = 10*50;
fs = 2000;
t = 0:1/fs:T-1/fs;
x = sawtooth(pi*4000*t,1/2);
figure(1)
plot(t,x)
grid on
figure(2)
pspectrum(x,fs,'Leakage',0.91)

 채택된 답변

Paul
Paul 2024년 2월 25일
편집: Paul 2024년 2월 25일
Do you want a triangle or a sawtooth? Assuming the former as stated in the question, use tripuls
%T = 10*50;
fs = 2000;
t = -4000*pi:1/fs:4000*pi;
numel(t) % lots of data points
ans = 50265483
x = tripuls(t,pi*8000,0);
figure(1)
plot(t,x)
xline(4000*pi);xline(-4000*pi);

댓글 수: 3

S
S 2024년 2월 25일
Oh thank you! So to make it go from -4000pi to 4000pi on the horizontal axis would I change the x=triplus line?
Paul
Paul 2024년 2월 25일
The time vector already spans -4000*pi to 4000*pi. I added some lines to the plot to make that clear.
S
S 2024년 2월 26일
oh thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

S
S
2024년 2월 24일

댓글:

S
S
2024년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by