필터 지우기
필터 지우기

how many times is a value repeated in a table

조회 수: 1 (최근 30일)
Fedi Chaarana
Fedi Chaarana 2021년 7월 14일
답변: Sulaymon Eshkabilov 2021년 7월 14일
Hello
I have a mdf4 datei that i read with matlab and was converted into timetable. I converted this timetable to a normal table and i want to analyse the values of the first row. Each values was taken after 0,1s so and are one of these following possibilities{20,50,100} with some tolerance.
My question: how can i create a loop that tells me for how many times a values is repeated on the table ?
thanks in advance

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 7월 14일
N20=sum(tab.prob(:,1)==20); % Times of 20s
N50=sum(tab.prob(:,1)==50); % Times of 50s
N100=sum(tab.prob(:,1)==100); % Times of 100s

추가 답변 (1개)

Ive J
Ive J 2021년 7월 14일
You can play with groupSummary which offers lots of options:
tab = table(repmat([20; 50; 100], 20, 1), string((1:60).'), 'VariableNames', {'prob', 'id'});
head(tab)
ans = 8×2 table
prob id ____ ___ 20 "1" 50 "2" 100 "3" 20 "4" 50 "5" 100 "6" 20 "7" 50 "8"
tabSum = groupsummary(tab, 'prob')
tabSum = 3×2 table
prob GroupCount ____ __________ 20 20 50 20 100 20

카테고리

Help CenterFile Exchange에서 Vehicle Calibration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by