String manipulation with printing of characters
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Liz
am 17 Nov. 2020
Beantwortet: Walter Roberson
am 17 Nov. 2020
The question is:
Write a script that will prompt the user to enter a word, and then print the first character in the word. For example, the output might look like this:
>> Enter a word: howdy
The word howdy starts with the letter ‘h’
How do you print the first character? I can do the:
>> word = input('Enter a word: ','s')
I do not know to display the first character.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
NAVNEET NAYAN
am 17 Nov. 2020
I think the following code should work
t=input('Enter a word: ', 's');
disp(t(1));
2 Kommentare
NAVNEET NAYAN
am 17 Nov. 2020
Try this and see whether it solves the purpose or not. I think it should work
t=input('Enter a word: ', 's');
char(t(1));
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!