MATLAB triangular wave series convergence with period T=2

34 replies · 14K views · last reply
lewando said:
Also, one final thing: what is the purpose of doing:

% Make wave start at 0
s = s - s(1);

This introduces an artificial offset to the data. Is this required?

It's not really required. I re-ran is by doing s=0; before all the maxterms and i did get a similar amplitude range for all 3 plots. The peaks don't vary much. The question asks us to provide the peak value hence the reason for hard coding it. Is there a simple bit of code that could automatically provide it?
 
Try:

m = max(s)
title_string = sprintf('maximum is: %f',m)
title(title_string)

As for your offset-- then don't do it. It is affecting the peak value you are reporting.
 
I guess the peak value is the same for all 3 plots. The only noticeable difference is the sharpening of the edge of the triangle. I assume as convergence occurs there will be less visible change.
 
Attachments
  • MATLAB figure with three stacked plots of a triangular wave against time from -1 to 1 s, titled Graph 1 (6 n values), Graph 2 (10 n values) and Graph 3 (30 n values), each with peak value 1.192129; beside it a second figure titled System C showing a step-like waveform with ripples near the transitions.
    graphs.jpg
    36.8 KB · Views: 505
They should not be the same. They should be close, but N=30 should give you a larger peak than N=6. Just considering the summation at the t=0, cos(0)=1, point.
 
Ah it was because i didn't put m=max(s) before every maxterm. I have did that now and got a larger peak. 1.192, 1.209 and 1.225