Why does my code looks weird (solved, thanks everyone for helping)

2 views (last 30 days)
  2 Comments
David Hill
David Hill on 20 Apr 2021
Too many unknowns to answer the question. An example would be good.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Apr 2021
You set the String to one letter. Then you do the next iteration and set the string to the next letter, overwriting the previous.
You need to accumulate the letters into something and then set that as the string after the loop
  6 Comments
Walter Roberson
Walter Roberson on 20 Apr 2021
letters = {};
for K=1:length(msg)
[~, index] = ismember(msg(K), LC);
if index > 0
letters{k} = morse{index};
else
letters{K} = '?';
end
end
converted_morse_words = strjoin(letters, ' ');
set(handles.text2,'string',converted_morse_words);
Ashley Siu Cheng Kok
Ashley Siu Cheng Kok on 20 Apr 2021
Edited: Ashley Siu Cheng Kok on 20 Apr 2021
that absolutely helps. Thank you very much!!! really appreciate your kind help and patience. have a nice day !!

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!