필터 지우기
필터 지우기

How to count the number of different strings in a string list?

조회 수: 15 (최근 30일)
Paramonte
Paramonte 2021년 1월 18일
댓글: Steven Lord 2021년 4월 15일
Dear All
I would need some help on this:
I have the following string list:
AAA
ABB
CDE
ABB
CCR
AAA
FDR
I would need to count the different strings in this list which is, in this example 5, and this would be my output.
The acual list may have undreds of strings.
Many thanks in advance!
Para

채택된 답변

Mischa Kim
Mischa Kim 2021년 1월 18일
Hi, use
str = {'AAA','ABB','CDE','ABB','CCR','AAA','FDR'};
numstr = numel(unique(str))
  댓글 수: 3
Richard Cornish
Richard Cornish 2021년 4월 15일
This is useful. I want a frequency plot of each unique string - any ideas?
Steven Lord
Steven Lord 2021년 4월 15일
str = {'AAA','ABB','CDE','ABB','CCR','AAA','FDR'};
histogram(categorical(str))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by