Effacer les filtres
Effacer les filtres

Number of times an element appears

1 vue (au cours des 30 derniers jours)
Lorenne
Lorenne le 11 Mai 2018
Rouvert : Guillaume le 11 Mai 2018
If i have a vector prize = [3;5;1;2;1] and the year =[2007;2018;2011;2011;2018] How do I find the number of times each year appears in 'year'? Without using accumarray function

Réponses (1)

Guillaume
Guillaume le 11 Mai 2018
I don't see what prize has to do with your question. The number of times each of something appears in a set is called the histogram, which you can obtain easily with histcounts or the deprecated histc.
If you are banned from using any of these functions because this is homework, then you'll have to use a for loop. It's really not complicated to figure out what needs to go in the loop.

Catégories

En savoir plus sur Data Distribution Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by