Need help to plot sawtooth wave Matlab

2 ビュー (過去 30 日間)
Jeff
Jeff 2014 年 12 月 4 日
コメント済み: Jeff 2014 年 12 月 4 日
Hello everyone! Thank you all for your help in advance. I have a HW problem that asks to create sawtooth plot using the following: SUM where n=1,2,3,4.... of
(amp/(n*pi))*sin(2*pi*n*frequency*time);
Can anyone tell me if this equation by itself can produce sawtooth plot? Does it need any mods to produce necessary graph. P.S. no use of sawtooth built in functions. Thank you all !

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 12 月 4 日
Jeff - I think that it is almost the sawtooth just missing an amp/2 factor which you then subtract the above sum from. See sawtooth for details.
To see the sawtooth take shape as n increases, try the following code
close all;
figure;
% define the number of samples per second
Fs = 8192;
% create your one second time vector
t = linspace(0,1-1/8192,Fs);
% define your frequency and amplitude
f = 2;
amp = 1;
% plot dummy data
h=plot(NaN,NaN);
res = amp/2;
for k=1:n
res = res - (amp/(k*pi))*sin(2*pi*k*f*t);
set(h,'XData',t,'YData',res);
pause(0.1);
end
  1 件のコメント
Jeff
Jeff 2014 年 12 月 4 日
It works! Just needed n values. I have been beating around the bush for some time now, you are awesome and I really appreciate your help. Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by