Fourier series sawtooth wave

조회 수: 31 (최근 30일)
Paul Velasco
Paul Velasco 2019년 11월 13일
편집: randerss simil 2021년 2월 16일
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
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);

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

답변 (2개)

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:

randerss simil
randerss simil 2021년 2월 16일
편집: randerss simil 2021년 2월 16일
T=input('what is the period');
p=input('how many coefficients');
t=linspace(0,3*T,100);
N=10;
bp=sin(90)/90 - cos(0);
ap=sin(90) - sin(45)^2/90;
xsum=0; % avoid standard matlab functions e.g. sum
for p=1:N
xsum=(xsum+(N*ap*cos(2*pi*p.*t/T))+(N*bp*sin(2*pi*p.*t/T))); % use dot for indexing element wise multiplication
end
F=xsum;
figure(1);
plot(t,F);
  댓글 수: 1
randerss simil
randerss simil 2021년 2월 16일
편집: randerss simil 2021년 2월 16일
Try the above , may be you have to adjust values for bp and ip to get accurate sawtooth waves

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by