Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
determining if a value repeats within a vector
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to determine the value of an integer that repeats 3 times within a vector of 5 elements.
I am trying to code Yahtzee with basic MATLAB knowledge, and am stuck.
An example is a vector of [ 1, 2, 3, 1, 1] and I want to be able to verify that there are 3 ones in the vector.
2 commentaires
per isakson
le 24 Avr 2019
Try
>> val =[ 1, 2, 3, 1, 1];
>> [N,edges] = histcounts( val, [unique(val),inf] )
N =
3 1 1
edges =
1 2 3 Inf
>> edges( N==3 )
ans =
1
>>
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!