%PROGRAM: HISTOGRAM AND GRAPH TOGETHER hold on % this allows you to put more than one % graph in the same figure c=round(10*rand(100,1)-5); % this generates some random numbers t = -5:.02:5; % this introduces the variable t. % t=-5 is the starting value % t increments in steps of .02 % until t is 5 hist(c) % this draws the histogram for c plot(t, 10*cos(5.5*t)+5,'r') % this plots the function given % the 'r' means make it red % the first t is the variable % note above we said how often % we want to sample. % note: if you zoom in you'll % see not graphing smoothly, % but sampling. y = -5:2:5; plot(y, 5*cos(y)+5,'k') % this plots another function % note here I'm sampling every % 2 units. that's why the cosine % function doesn't look too good % the 'k' means blacK. 'b'=blue