How can I change line for the instruction page of the experiment?

1 回表示 (過去 30 日間)
Jinah Lee
Jinah Lee 2017 年 3 月 17 日
コメント済み: Jinah Lee 2017 年 3 月 24 日
Hello everyone, I'm trying to figure out to change line for my instruction. I use sprintf to display text on the plot. However, I have no idea how to change line for my instruction. Here's my code for instruction page. Please let me know what should I change. Thanks a lot!!
fig=figure;
set(fig, 'Position', get(0,'Screensize')); % Maximize figure.
instruct=sprintf('Put your right index finger on P and put your left index finger on Q.You will see the target(★) either left or right square.If the target is on the right, please press P. If the target present on the left, please press Q.Please response as soon as you can.');
textToDisplay = text(0,0.5,instruct); %display text in the graph
set(textToDisplay,'Fontsize', 15,'Color','k') %set the fontsize and color of 'x'
axis off
pause
clf

採用された回答

Alisha Schor
Alisha Schor 2017 年 3 月 21 日
By "change line," do you mean add a line break? Assuming this is the case, you can add the regular expression '\n' to your string.
For example:
instruct = sprintf('My instruction on \ntwo lines')
produces:
instruct =
My instruction on
two lines
Note that the sprintf command immediate recognizes '\n' and inserts a line break, even though there is not a space between that and the word 'two'.
  1 件のコメント
Jinah Lee
Jinah Lee 2017 年 3 月 24 日
Yep!!!! totally worked!! I appreciate your help!!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by