Help needed with matlab code. Sawtooth wave.
이전 댓글 표시
Here is a code, which calculates square wave frequency and phase spectrum. What I should change to make it plot sawtooth wave?
clc, clear
t=-3:1e-3:3;
tau=1;
T=2*tau;
U=1;
N=10;
K=0:N
k0=0
Sk1=(2*U)*(sin(K*pi/T))./(K*pi)
Sk1(1)=0.5
figure(1)
subplot(211)
stem(K, abs(Sk1))
subplot(212)
stem(K, phase(Sk1))
S=Sk1(1)
for K=1:N
S = S + abs(Sk1(K+1))*cos(K*pi*t+phase(Sk1(K+1))…
end
figure(2)
plot(t,S), grid
댓글 수: 2
Jan
2011년 12월 17일
Please format your code as explained in the "Markup help" link on this page. I've done this for you this time.
Daniel Shub
2011년 12월 18일
What is the difference, in amplitude and phase, between a square wave and a sawtooth wave? Where are the phase and amplitude set in your code?
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!