function fs_step % Plot the Fourier sine series of a step function clc hold off n=input('Insert the umber of Fourier modes, n = '); % Grid x=[-1:.002:1]; f=0; for k=1:n km1=2*k-1; f=f+sin(km1*pi*x)/km1; end f2=4*f/pi; plot(x,f2,'-k','linewidth',1.8) hold on xlabel('$x$','Interpreter','latex','fontsize',36) ylabel('$f^{(N)}(x)$','Interpreter','latex','fontsize',36) % Plot a point at the origin z=[0 0]; x=[0 0]; plot(x,z,'ok','markersize',10,'markerfacecolor','k') set(gca,'FontSize',36) set(gca,'Ytick',[-1.5:.5:1.5],'linewidth',1.6) set(gca,'Xtick',[-1:.5:1],'linewidth',1.6) % Create string to label graph with n str1={'$N = $'}; str2=num2str(n); str=strcat(str1,str2); text(-0.8,1,str,'Interpreter','latex','fontsize',36) set(gcf, 'Units','centimeters','Papersize',[36,36]) set(gcf, 'Units','centimeters','Position',[3 3 24 20])