Quantcast
Viewing all articles
Browse latest Browse all 41

One variable with multiple values depending on conditions

I am relatively new to MATLAB and programming in general, so to better familiarize myself with it, I have been writing scripts for simple games (coin flip, dice roll, etc.) I wanted to try something more complex and wrote a script for a game of blackjack. It works fine except for the fact that I can only assign one value to aces (as opposed to two). I have it set up as a conditional statement:
A=[1,11];
if (hand-A)<=10
     A=11
else
     A=1
end
I have discovered that this does not work and A comes up as 1 no matter what. What exactly am I doing wrong, or am i going about this the wrong way altogether?
Thank you

Viewing all articles
Browse latest Browse all 41

Trending Articles