% % TEST 1 - SECTION 2 % Sample Solutions % clear all; % QUESTION #1: % Generate a clock signal [1 0 1 0 ... ] of length 1000. clock = reshape([ones(1,500); zeros(1,500)], 1, 1000); % QUESTION #2: % Find angle (in dgrees) where two curves meet. x = 0 : 0.1 : 2*pi; y1 = sin(x); y2 = cos(x); pos = x(find( abs(y1-y2) == min(abs(y1-y2)) )) * 180 / pi; % QUESTION #3: Open a figure window and... % a) Make the background blue set(gcf, 'Color', 'Blue'); % b) Print your name (and nothing else) in the figure title set(gcf, 'Name', 'Matt Lab'); set(gcf, 'NumberTitle', 'off'); % c) Make the axes background white axes; set(gca, 'Color', 'White'); % d) Make the axis color red set(gca, 'Xcolor', 'Red', 'YColor', 'Red'); pause; % QUESTION #4: z = sin(sqrt(x^2 + y^2)) % a) Plot z over the range -pi to pi in increments of 0.2 x = -pi : 0.2 : pi; y = x; [ X, Y ] = meshgrid(x, y); z = sin(sqrt(X.^2 + Y.^2)); mesh(z); pause; % b) Colormap such that high vales are hot and low values are gray colormap([hot; gray]);