MATLAB: The first letter of the output string will be the first letter of the first word of the sentence.

homeworkstring

Whose input is a sentence (as a string). The words of the sentence are separated by single blanks, and there is a dot at the end of the sentence. The output will be a word (as a string) created by alternatingly picking the first and last letters of the words of the sentence:
The first letter of the output string will be the first letter of the first word of the sentence. The second letter of the output string will be the last letter of the second word. The third letter will be the first letter of the third word, and so on. (You may NOT use any built-in functions except size, length, rem and mod)
Example:
If Sentence= 'The tree nut sings in no need.'
and Out = first_last_letters (Sentence)
Out will be Out='Tension'

Best Answer

You can split your string using a delimiter. which in your case is space
new_s = split(s,' ')
create a dummy string ans and append the required fields
Run a loop on new_s so that you can access first and last chars as follows
% for odd index string
ans = append(ans,new_s{i}(1))
% for even index string
ans = append(ans,new_s{i}(end))
Try this !