MATLAB: Searching for specific word containing specific letters and removing last element in the string

strings

I have a wordbank containing only one word for every line. I want to sort of the words in struct, such that wordbank.a=airplane, where the beginning of the word that is stored in the struct starts with its field name, 'a' and then i'll have wordbank.b=ball….[row,1] array and for 'c' 'd' until the letter 'z'.. my question is, how do I make sure that the word that are stored with a specific goes to the right field of letters?
another question is,
if i have a string a=catss,and I want to make it a=cats only.How do I find the words with 's' at the end of the each word so that I could remove every word all plural forms of a word that end in s. If any word that is checked contain word+s, thre plural form must be removed.

Best Answer

For the first part of your question:
wordlist = {'airplane', 'ball', 'bell', 'bull'};
letters = 'a':'z'; % a, b, c, ..., z
wordstruct = struct;
for ichar = 1:length(letters)
wordstruct.(letters(ichar)) = cell.empty;
end
for iword = 1:length(wordlist)
wordstruct.(wordlist{iword}(1)){end+1} = wordlist{iword};
end
I have no idea what you are asking in the second part. Maybe something like:
x = wordlist;
for iword = 1:length(wordlist)
if strcmp(wordlist{iword}(end), 's')
x{iword} = wordlist{iword}(1:(end-1));
end
end