Leaving a blank line between inputs
250 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Geoff
2012-5-31
input('\nsome question :', 's')
2 个评论
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
2012-5-31
fprintf(1, '\n');
perhaps
1 个评论
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 Center 和 File Exchange 中查找有关 Help and Support 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!