필터 지우기
필터 지우기

Sorting Values my Integer and Decimal Values

조회 수: 3 (최근 30일)
MattLab
MattLab 2022년 9월 30일
답변: Chunru 2022년 9월 30일
Hello, I am attempting to create a poker hand Analyser. Right now I have all cards (2-A) correlated to an integer value (2-14). Then depending on their Suite (Heart, Diamond,Spade,Club) I add a decimal value ( .1, .2, .3, .4). Is there a way to have my code differentiate between the integers and decimal values?
For ex.) A pair would be 8.1 and 8.2.
and a flash would be 2.1 , 3.1 , 4.1, 5.1, 6.1
I want to say something like:
if integer= integer then hand is a pair
if deciemal = deciemal then we have a flush
Thank you

채택된 답변

Chunru
Chunru 2022년 9월 30일
p = [8.1 8.2];
if floor(p(1)) == floor(p(2))
disp("A pair.")
end
A pair.
f = [2.1 , 3.1 , 4.1, 5.1, 6.1];
if all(abs(diff(mod(f,1))) < 1e-5)
disp("A Flush")
end
A Flush

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by