필터 지우기
필터 지우기

I am trying to display multiple lines of centered text

조회 수: 20 (최근 30일)
Adam Vilanova-Goldstein
Adam Vilanova-Goldstein 2022년 2월 1일
댓글: Turlough Hughes 2022년 2월 1일
I am trying to ask a question that requires 2 lines of centered text but I cannot get the line break to work. This is what I have so far.
chr = 'On a scale of 0 to 8, how much control did you have over the target circle? '; %% this is where I want the break
chr = [chr '0 = no control & 8 = complete control'];
formText(wPtr, chr ,xMid,yMid,[000 000 000])
Screen('Flip',wPtr);
exit=0;
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2022년 2월 1일
@Adam Vilanova-Goldstein - can you add a \n to the end of the first sentence like
chr = 'On a scale of 0 to 8, how much control did you have over the target circle?\n';
chr = [chr '0 = no control & 8 = complete control'];
?
Adam Vilanova-Goldstein
Adam Vilanova-Goldstein 2022년 2월 1일
When I did that, the \n showed up in the text

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

답변 (1개)

Turlough Hughes
Turlough Hughes 2022년 2월 1일
Here's one way:
t = ["On a scale of 0 to 8, how much control did you have over the target circle?";
"0 = no control & 8 = complete control"];
t = strjust(pad(t),'center');
fprintf('%s\n',t)
  댓글 수: 2
Adam Vilanova-Goldstein
Adam Vilanova-Goldstein 2022년 2월 1일
Thank you. I will try this. Does this method allow for font/size/color customization?
Turlough Hughes
Turlough Hughes 2022년 2월 1일
You can change fonts using the "Fonts" section in preferences and that will affect all of the fonts in the command window. For emphasis/customisation of only part of the displayed text in command window, the only one I know is boldface:
disp('<strong>Bold Font</strong> Regular Font')
Bold Font Regular Font

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

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by