source('utils.R') t = seq( 0, 60, length.out=500 ) n = 15 g = u_sub_c( t, 0 ) for( k in 1:n ){ g = g + (-1)^k * u_sub_c( t, k*pi ) } #postscript("../../WriteUp/Graphics/Chapter6/sect_4_prob_21_g_t_plot.eps", onefile=FALSE, horizontal=FALSE) plot( t, g, type='l', xlab='t', ylab='g(t)' ) grid() #dev.off() # Plot the solution: # t = seq( 0, 60, length.out=1000 ) y = 1 - cos(t) for( k in 1:n ){ y = y + (-1)^k * u_sub_c( t, k*pi ) * ( 1 - cos( t - k*pi ) ) } #postscript("../../WriteUp/Graphics/Chapter6/sect_4_prob_21_y_t_plot.eps", onefile=FALSE, horizontal=FALSE) plot( t, y, type='l', col='black', xlab='t', ylab='y(t)' ) grid() #dev.off()