% % Written by: % -- % John L. Weatherwax 2007-07-01 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clc; close all; clear; alpha = +2; % the value of \alpha y_lim_min = -2.0; y_lim_max = 2.0; x = linspace( -6, +6, 100 ); y = zeros(1,length(x)); inds = find(x>0); y(inds) = -x(inds); % the ramp function: % plot( x, y, '-' ); axis( [-6, +6, y_lim_min, y_lim_max] ); title('initial ramp function'); saveas( gcf, '../../WriteUp/Graphics/Chapter2/chap_2_prob_9_initial_ramp.eps', 'psc2' ); % the flipped ramp function: % plot( x, fliplr(y), '-' ); axis( [-6, +6, y_lim_min, y_lim_max] ); title('flipped ramp function'); saveas( gcf, '../../WriteUp/Graphics/Chapter2/chap_2_prob_9_flipped_ramp.eps', 'psc2' ); % the flipped ramp shifted by a to the right: % a = 3/4; yF = fliplr(y); xS = x+a; % shift x by a plot( xS, yF, '-' ); axis( [-6, +6, y_lim_min, y_lim_max] ); title(['flipped ramp function shifted right by ',num2str(a)]); saveas( gcf, '../../WriteUp/Graphics/Chapter2/chap_2_prob_9_flipped_shifted.eps', 'psc2' ); % plot the fixed step function on top of this: % y = zeros(1,length(x)); inds = find(x>-alpha & x<+alpha); y(inds) = 1; plot( xS, yF, 'b-' ); hold on; plot( x, y, 'r-' ); axis( [-6, +6, y_lim_min, y_lim_max] ); title(['alpha=',num2str(alpha), '; a=',num2str(a)]); saveas( gcf, '../../WriteUp/Graphics/Chapter2/chap_2_prob_9_flipped_shifted_w_step.eps', 'psc2' );