Appendix B Selected MATLAB® Programs
B.1 Program for Representation of a Function f1(t) = sin(πt) Using Walsh/BPF Function (Examples 2.1 and 2.3)
clcclear all%%— — — — — — — — — — EXACT SOLUTION — — — — — — — — — — — -%%k=0.01for i=1:101 t(i)=(i-1)*k FUNC(i)=sin(pi*(i-1)*k);end %%— — — — — - FUNCTION PLOTTING— — — — — — %%plot(t,FUNC,’k’) % plot the exact functionhold on%%— — — — — — — — — — SOLUTION VIA BPF — — — — — — — — — — -%%clear allclcsyms tfunc=sin(pi*t) % the function to be approximatedT=1 % total time consideredm=8 % no. of Walsh componentsh=T/m % length of each intervalfor i=1:m x1(i)=double(m*int(func,((i-1)*h),(i*h))); ...
Get Power Electronic Systems now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.