How to find and chart the frequency of a letter in column with histogram.

4 visualizaciones (últimos 30 días)
N/A
N/A el 28 de Jul. de 2021
Comentada: Star Strider el 29 de Jul. de 2021
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.

Respuestas (1)

Star Strider
Star Strider el 28 de Jul. de 2021
Perhaps —
Col = {'HFHFHSHHAJHJA'; 'HSAJHFGFSAGJ'; 'HSGHSFFJHJ'};
T = cell2table(Col)
T = 3×1 table
Col _________________ {'HFHFHSHHAJHJA'} {'HSAJHFGFSAGJ' } {'HSGHSFFJHJ' }
RowSum = cellfun(@(x)sum(x=='H',2),T{:,1})
RowSum = 3×1
6 2 3
ColSum = sum(RowSum)
ColSum = 11
.
  4 comentarios
N/A
N/A el 29 de Jul. de 2021
So basically it would be a histogram showing the percentage of H in the data set. Sorry for not being clear enough.
Star Strider
Star Strider el 29 de Jul. de 2021
In that event, just use bar with ‘H_Pct_Row’.

Iniciar sesión para comentar.

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by