2 - 'Club' C=8 elseif SuitB== 'Spde' C=6 else SuitB==...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
2/ function [B,M]= matoperation(A) [m, n]= size(A); for i=1:m; for j=1:n; B(i,j)=A(i,j)*A(i,j); M(j,i)=A(i,j); end end end [AES1,AT1]=matoperation(A1) AES1 = 9 4 1 25 16 9 4 16 25 AT1 = 3 -2 1 5 4 -3 2 -4 -5 [AES2,AT2]=matoperation(A2) AES2 = 36 9 4 16 25 9 AT2 = -6 5 4 2 3 -3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
3/ function file function [suit,marking]= card_gen suit=rand; marking=rand; if suit<0.25; suit= 'Dmd' elseif suit<0.5; suit= 'Spde' elseif suit<0.75; suit= 'Club' ; else suit<1; suit= 'Hart' ; end if marking<0.2; marking= 'Ten' elseif marking<0.4; marking= 'jck' elseif marking<0.6; marking= 'Qun' elseif marking<0.8; marking= 'Kng' else marking<1; marking= 'Ace' end end Script file %Player A [SuitA, MarkingA]=card_gen; %Hence is how i calculate the point if SuitA == 'Dmnd' A=10 elseif SuitA== 'Club' A=8 elseif SuitA== 'Spde' A=6 else SuitA== 'Hart' A=4 end if MarkingA== 'Ten' B=10 elseif MarkingA== 'Jck' B=12 elseif MarkingA== 'Qun' B=14 elseif MarkingA== 'Kng' B=16 else MarkingA== 'Ace' B= 18 end PointA=A+B; %Player B [SuitB, MarkingB]=card_gen;
Background image of page 2
if SuitB == 'Dmnd' C=10 elseif SuitB==
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 'Club' C=8 elseif SuitB== 'Spde' C=6 else SuitB== 'Hart' C=4 end if MarkingB== 'Ten' D=10 elseif MarkingB== 'Jck' D=12 elseif MarkingB== 'Qun' D=14 elseif MarkingB== 'Kng' D=16 else MarkingB== 'Ace' D=18 end PointB=C+D; fprintf( 'Player A card is %s %s and his/her point is %d.\n' ,SuitA, MarkingA, PointA) fprintf( 'Player B card is %s %s and his/her point is %d.\n' ,SuitB, MarkingB, PointB) if PointA>=PointB; fprintf( '\nPlayer A is the winner\n' ); elseif PointB>=PointA; fprintf( '\nPlayer B is the winner\n' ); else PointA==PointB; fprintf( '\nThere is no winner\n' ); end Player A card is Club Qun and his/her point is 22. Player B card is Hart Qun and his/her point is 18. Player A is the winner Player A card is Spde Ten and his/her point is 16. Player B card is Spde Qun and his/her point is 20. Player B is the winner...
View Full Document

This note was uploaded on 11/10/2010 for the course PGE 323K taught by Professor Lake during the Spring '08 term at University of Texas.

Page1 / 3

2 - 'Club' C=8 elseif SuitB== 'Spde' C=6 else SuitB==...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online