% % Homework #5: Advanced Graphics & Plotting in Matlab % Sample Solution % % Start fresh clear all; % Define equations t = [ -8*pi/3 : .01 : 8*pi/3 ]; x = cos(t); y = exp(-t).*cos(10*t); % Do the plots and turn on the grid for later... h1 = subplot(211); % Top plot, solid line in blue l = plot(t, x, 'b-'); % We'll use this line object later xlabel('\omega'); % Label X & Y while we're here... ylabel('y = cos(\omega)'); grid on; h2 = subplot(212); % Bottom plot, dashed line in red plot(t, y, 'r--'); xlabel('\omega'); % Label X & Y while we're here... ylabel('y = e^{\omega}cos(10\omega)'); grid on; pause % Label the figure *window*. % NOTE: The figure window is not the same as the figure itself. The % figure itself should be title()'ed with a meaningful % description of the graph. set(gcf, 'Name', 'Matt Lab'); % Print my name set(gcf, 'NumberTitle', 'off'); % Don't print the Figure #. pause % Change axis color set(h1, 'XColor', 'b', ... % Blue axis on the top 'YColor', 'b'); set(h2, 'XColor', 'r', ... % Red axis on the bottom 'YColor', 'r'); pause % Set backgroup color set(h1, 'Color', 'r'); % Red background on the top set(h2, 'Color', 'b'); % Blue background on the bottom pause % Set grid styles to dots. This is the default value. set(h1, 'GridLineStyle', ':'); set(h2, 'GridLineStyle', ':'); pause % Set up axis labels. Been there; done that. See above. % Now set up the font... set(h1, 'FontName', 'Helvetica', 'FontSize', 14); set(h2, 'FontName', 'Helvetica', 'FontSize', 14); pause % Set line styles... Did that in the original plot() statement. % Set line thickness... set(h1, 'Units', 'Points', 'LineWidth', 3); set(h2, 'Units', 'Points', 'LineWidth', 3); pause % Change the blue line to white (need the line object l for h1) gca=h1; set(l, 'Color', 'white');