Leaving a blank line between inputs

241 views (last 30 days)
I apologize if this is a rookie question--I'm still learning MATLAB. I have a script which requires the user to enter inputs via the input('some question :', 's') prompt. I know that '\n' skips to the next line in the 'some question' part of the argument. I would like to do something similar, but '\n' doesn't seem to do the trick.
Because my script prompts the user with multiple questions in a row, I would like to leave a blank line between each prompt to improve readability. Is this possible? Thanks in advance.
  2 Comments
Kaome O'Faire
Kaome O'Faire on 19 Sep 2016
fprintf('\n') underneath the line you're trying to make a space for.
Giuseppe Degan Di Dieco
Giuseppe Degan Di Dieco on 18 Apr 2021
Dear Kaome,
thank you!
I didn't think of it!
best!

Sign in to comment.

Accepted Answer

Geoff
Geoff on 31 May 2012
input('\nsome question :', 's')
  2 Comments
Wyatt
Wyatt on 31 May 2012
Thanks much! So simple in retrospect...
Image Analyst
Image Analyst on 1 Jun 2012
Why not move from the primitive command line age into the modern GUI age with inputdlg() instead?

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 31 May 2012
fprintf(1, '\n');
perhaps
  1 Comment
Daniyal Altaf Baloch
Daniyal Altaf Baloch on 11 Apr 2020
worked perfect.
just add before or after the "input prompt" depending where you want the blank line.
For example in my case I did so:
prompt = ['Enter <1> for Case 1:Boost control or' newline 'Enter <2> for Case 2: Boost + inj.Fuel control:' newline ': '];
xx = input(prompt);
fprintf('\n') % this command skips a line in the Command Window just to improve readability
and the result in Command Window shows like this"
Hence now the cursor moves to the third line where I enter my value (in this case "1")

Sign in to comment.

Categories

Find more on Help and Support 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!