## Fourier series sawtooth wave

### Paul Velasco (view profile)

on 13 Nov 2019 at 0:51
Latest activity Answered by Urmila Rajpurohith

### Urmila Rajpurohith (view profile)

on 15 Nov 2019 at 12:58
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);

Walter Roberson

### Walter Roberson (view profile)

on 13 Nov 2019 at 0:53
Paul Velasco

### Paul Velasco (view profile)

on 13 Nov 2019 at 6:56
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);