MATLAB: How to use input to make a string and fprintf to output different parts of the string

fprintfinput

I'm trying to write a program that will allow the user to enter their name as a string. And then using fprintf, output the user’s name as well as the first and last letter of the users name separately.

Best Answer

Use the 's' option to read the input as a string. E.g.,
name=input('enter your name ','s');
Then you can use fprintf with three different %s formats to print out name, name(1), and name(end).