preview

Math Essay

Satisfactory Essays

clf % Clears figure theta = linspace(0,2*pi,50); % Creates circle from 50 points xc = 0.4*cos(theta); % Defines x coordinates for a circle with radius of 0.4 yc = 0.4*sin(theta); % Defines y coordinates for a circle with a radius of 0.4 N=6; % setting board dimensions W=7; board=zeros(W,N); % makes a 7 by 6 board bval=zeros(W,N); % Sets all the values in the bval matrix to zero for x=1:W, %Creates for...loop that iterates through the number of collumns and number of rows for y=1:N, board(x,y)=patch(x+xc,y+yc,[1 1 0]); % Creates patch graphic of yellow % circles centered at increasing zeroes according to N & W end end axis([0 W+1 0 N+1],'square') % Squares a 7x6 axis set(gca,'XTick',[]) % …show more content…

%Horizantal for k=1:6 %Creates for... loop from 1 to 6, the number of rows for l=1:4 %Creates for... loop from 1 to 4, the number of possible four in rows in any given row if bval(l,k)+bval(l+1,k)+bval(l+2,k)+bval(l+3,k) == 4, %checks if each four in a row adds up to four title ('Red Wins'); %adds title, Red Wins, if there are four in a row end end end %Vertical for l=1:7 %Creates for... loop from 1 to 7, the number of collumns for k=1:3 %Creates for... loop from 1 to 3, the number of possible four in rows in any given collumn if

Get Access