I am trying to plot this wave and its fourier approximation for first 5 harmonics. This is what I want the final result to be like (note the wave approximated in the picture is a square wave)
This is the wave I want to approximate:
I know how to plot a sawtooth wave using the sawtooth funciton I was confused by the delay between the sawtooths in the picture. I tried using a piecewise function repeated 3 times to generate the wave.
f = @(x)[.5*x.*(0<=x & x<=2) + 0.*(2<=x & x<=3) + ((.5*x)-1.5).*(3<=x & x<=5)];
x = linspace(0,3);
intvl = [-6 6];
pfx = repmat(f(x+1),1,diff(intvl)/3);
px = linspace(intvl(1),intvl(2),length(pfx));
This code can generate the sawtooth wave with some problems as shown here:
Now my question is how to properly plot the function in the original question then plot a fourier transform for it. The fourier transform for this normal sawtooth below is given where L is half the length of the sawtooth.