MATLAB Answers

Fourier series sawtooth wave

40 ビュー (過去 30 日間)
Paul Velasco
Paul Velasco 2019 年 11 月 13 日
回答済み: Urmila Rajpurohith 2019 年 11 月 15 日
Im trying to create a sawtooth wave but the code i have gives me a square wave. Not sure what i need to change, maybe my values for ap and bp? Sorry im not very good at matlab. Thanks in advance.
T=input('what is the period');
p=input('how many coefficients');
t=linspace(0,3*T,100);
N=10;
bp=sin(80)/320 - cos(80)/4;
ap=sin(80)/4 - sin(40)^2/160;
sum=0;
for p=1:N
Sum=(Sum+(N*ap*cos(2*pi*p*t/T))+(N*bp*sin(2*pi*p*t/T)));
end
F=Sum;
figure(1);
plot(t,F);

  2 件のコメント

Walter Roberson
Walter Roberson 2019 年 11 月 13 日
Paul Velasco
Paul Velasco 2019 年 11 月 13 日
These are the equations i have, they dont give me a sawtooth graph
syms t T p
T=input('what is the period');
p=input('how many coefficients');
y=10;
f=t/(2*T);
global ap bp
ap=(2/T).*int((f.*cos(p*2*pi*t/T)),t,0,T);
bp=(2/T).*int((f.*sin(p*2*pi*t/T)),t,0,T);

サインイン to comment.

回答 (1 件)

Urmila Rajpurohith
Urmila Rajpurohith 2019 年 11 月 15 日
You can use “sawtooth” function in MATLAB to create a sawtooth wave.
You can refer to below documentation for more information on “sawtooth” function.
you can also have a look at the similar question:

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by