How do I get user input and converts each character to specific string

 Accepted Answer

If i'm just supposed to guess, then:
% one char vec for each a b c, etc
symbols = {'.-' '..' '--' 'dee' 'ee' 'eff' 'gee'};
% input
invec = 'adgfcbe';
% assemble output
outtvec = horzcat(symbols{double(lower(invec))-double('a')+1})
outtvec = '.-deegeeeff--..ee'

4 Comments

i am using the edit text box for user to enter input is there anyway where i can get input from there
i am doing something like a translate program
If this is part of a gui, you'll have to deal with that in the callback that you specified for that object, or you'll have to otherwise access the appropriate properties of that object in order to get the string that's in the box.
i am currently still facing error output couldn't display in specific box

Sign in to comment.

More Answers (0)

Categories

Asked:

on 11 Apr 2022

Edited:

on 12 Apr 2022

Community Treasure Hunt

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

Start Hunting!