how to build a character array to show letters that appear multiple times in a word
Mostrar comentarios más antiguos
3 comentarios
Image Analyst
el 5 de Mayo de 2019
A simple example is needed. Do you mean a histogram of letter occurrences except that the bars in the histogram are the letters that each bar represents? I have no idea (other than that, which is probably wrong).
zoom
el 5 de Mayo de 2019
Image Analyst
el 5 de Mayo de 2019
Again "A simple example is needed."
Respuestas (1)
Navdha Agarwal
el 20 de Jun. de 2019
As I understand from your question, you want to build a character array of all those letters that appear multiple times in a word. For example if your word is 'mississippi', the character array should contain 'isp'.
The code for the above logic is
v = 'mississippi';
u = unique(v);
m = [];
for i = 1:length(u)
if(length(strfind(v,u(i)))>1)
disp(u(i))
m = [m,u(i)]
end
end
disp(m)
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!