Leaving a blank line between inputs

조회 수: 240 (최근 30일)
Wyatt
Wyatt 2012년 5월 31일
댓글: Giuseppe Degan Di Dieco 2021년 4월 18일
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
Kaome O'Faire
Kaome O'Faire 2016년 9월 19일
fprintf('\n') underneath the line you're trying to make a space for.
Giuseppe Degan Di Dieco
Giuseppe Degan Di Dieco 2021년 4월 18일
Dear Kaome,
thank you!
I didn't think of it!
best!

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff
Geoff 2012년 5월 31일
input('\nsome question :', 's')
  댓글 수: 2
Wyatt
Wyatt 2012년 5월 31일
Thanks much! So simple in retrospect...
Image Analyst
Image Analyst 2012년 6월 1일
Why not move from the primitive command line age into the modern GUI age with inputdlg() instead?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 5월 31일
fprintf(1, '\n');
perhaps
  댓글 수: 1
Daniyal Altaf Baloch
Daniyal Altaf Baloch 2020년 4월 11일
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")

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Help and Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by