% % Homework 3 (Monday class) - Sample solution % Examples of 2D Plotting Functions % clear all % Bar Graph data = [7 3 9 2 4 11 17 2 5 4 8]; % Generate some data bar( [0:length(data)-1], data ); % Plot, from 0<= x <= 10 title('Sample Bar Graph'); pause % Polar Graph theta = [0:0.01:2*pi]; % Theta in radians, NOT degrees. rho = 2*sin(theta) .* cos(theta); polar(theta, rho); hold rho = sin(theta + pi/4) .* cos(theta + pi/4); polar(theta, rho); title('Sample Polar Graph'); hold off pause % Histogram data = rand([1 100]); % Generate 100 random numbers hist(data, 10); % See how they were spaced title('Histogram of random data') pause % Fill range = [0:0.01:2*pi]; % Range in radians for sin() fill(range, sin(range), 'g'); % Plot the sin() w/ green fill title('One period of sin(x) w/ green fill'); pause % Quiver x = [0:10]; y = exp(x); quiver(x,y); title('Something simple with quiver()'); pause % Stairs steps = [1:10 10:2:20 20:-0.5:0]; stairs(steps); title('Sample Stairs Plot'); pause % Rose petals = [ 0:0.01:pi/2 pi/6:0.01:pi/3]; rose([petals pi/2petals pi+petals 3*pi/2+petals], 10) title('Does it look even a little bit like a rose?'); pause