How to find and chart the frequency of a letter in column with histogram.
조회 수: 2 (최근 30일)
이전 댓글 표시
I am looking for a way to find the frequency of a letter appearing in each line of a column in an excel file. The only column I am looking at has data like this: HFHFHSHHAJHJA, HSAJHFGFSAGJ, HSGHSFFJHJ. All I have found online so far, specifically through the mathworks resources is
T = readtable('Data.xlsx');
Sets = T{:, 9};
histogram(Sets, 40, 'FaceAlpha',0.4);
Basically I am trying to find the frequency H appears in each line and then the total frequency of the column.
Thank you for your help.
댓글 수: 0
답변 (1개)
Star Strider
2021년 7월 28일
Perhaps —
Col = {'HFHFHSHHAJHJA'; 'HSAJHFGFSAGJ'; 'HSGHSFFJHJ'};
T = cell2table(Col)
RowSum = cellfun(@(x)sum(x=='H',2),T{:,1})
ColSum = sum(RowSum)
.
댓글 수: 4
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!