How to count the amount of excell row

5 ビュー (過去 30 日間)
Putri Basenda Tarigan
Putri Basenda Tarigan 2020 年 11 月 13 日
編集済み: Akira Agata 2020 年 11 月 13 日
Hello.
I have an excel file with 80x10. for the first column, it has number from 1 to 10 but appear in many rows. for example number 1 appear in row 1,2,3. number 2 appear in row 4,5,6, etc. I want to calculate how many rows having the same number in that column. How to code this in Matlab?
Please help me.
Thank you

採用された回答

Akira Agata
Akira Agata 2020 年 11 月 13 日
編集済み: Akira Agata 2020 年 11 月 13 日
How about using accumarray function? The following is an example:
% Sample data (column vector containing 1~10 randomly)
data = randi(10,80,1);
% Count how many times 1~10 appears
count = accumarray(data,1);
% Arrange the result
number = (1:10)';
T = table(number,count);
>> T
T =
10×2 table
number count
______ _____
1 7
2 10
3 4
4 3
5 8
6 11
7 9
8 7
9 13
10 8

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by