% example figure making % % functions we will use: % hist % figure % plot % subplot % grid % xlabel % ylabel % title % % also try: % help hold % help plot figure; a = 2 * randn(1000,1) + 1; % a random normal with mean 1 and std dev 2 hist(a); % create a histogram xlabel('values of random normal'); ylabel('# of values'); a = -10 : 10 ; b = a.^2; figure; % open a new figure to plot on plot(a,b); % this will plot to new figure grid on; xlabel('a'); ylabel('a^2'); title('this is a parabola'); % let's create a figure with % 2 x 3 layout figure; n = 0; cols = { 'r' , 'g' , 'b' , 'k' , 'c' , 'k' }; % cell array of strings shapes = { '-' , '-.' , '+-' , '^-' , 'v-' , 'o-' }; % cell array of strings for i = 1 : 2 for j = 1 : 3 n = n + 1; subplot(2,3,n); % make the nth cell active to accept next plot % notes: 1. the optional third argument contains a COLOR and LINETYPE % e.g., 'r-' means red line, 'b-.' means blue dotted line, % etc. % 2. all additional arguments come in pairs of % (propertyname, propertyvalue) % here we use propertyname = 'linewidth' % propertyvalue = 2 linetypearg = [ cols{n} shapes{n} ]; % this concatenates two strings plot( a , (i*a).^j , linetypearg , 'linewidth' , 2 ); title(sprintf('%d*a^%d', i , j)); end end