% plot a random function with uniform step % sizes in [-.5, 5] x=rand(1,1000)-.5; y=cumsum(x); figure; hold on; grid on; title('Random Walk, 1000 steps'); plot(y) % plot a random function with step sizes % that are -1 or +1 x=2*round(rand(1,1000))-1; % gives -1 or +1 equally y=cumsum(x); figure; hold on; grid on; title('Random Walk, 1000 steps'); plot(y) % Use ezplot to plot sin and cos in same figure % Sin is plotted in blue by default, Cos in red figure; hold on; ezplot(@sin); ezplot(@cos); grid on; % Use ezplot to plot sin and cos in same figure % Force interval to be [0,4 pi] figure; hold on; ezplot(@sin,[0,4*pi]); grid on; ezplot(@cos,[0,4*pi]); % Use plot to plot sin and cos in same figure % over interval [0,4 pi] figure; hold on; t=[0:.1:4*pi]; plot(t,sin(t)); grid on; plot(t,cos(t)); % close all figures close all; % Use plot to plot sin and cos in same figure % over interval [0,4 pi]. Make Sin thick, make % Cos black and dashed figure; hold on; t=[0:.1:4*pi]; plot(t,sin(t),'LineWidth',5); grid on; plot(t,cos(t),'k--'); % use scatter to plot 100 random points in the % unit square [0,1] x [0,1] N=100; x=rand(1,N); y=rand(1,N); scatter(x,y); % the same, but fill the dots in and % make them red N=100; x=rand(1,N); y=rand(1,N); scatter(x,y,'r','filled'); % Now draw first 50 points using red dots % and second 50 using black +'s. Add grid % and title including numner of points and % today's date N=100; x=rand(1,N); y=rand(1,N); figure; hold on; title([num2str(N), ' Random points drawn on ', date]) scatter(x(1:50),y(1:50),'r','filled'); scatter(x(51:100),y(51:100),'k+'); grid on; % make a function that plots N random points function plot_rand_pts(N) x=rand(1,N); y=rand(1,N); figure; hold on; title([num2str(N), ' Random points drawn on ', date) scatter(x,y,'k','filled'); return