DrawFormattedText error using Psychtoolbox

I'm trying to set up a simple test experiment using Psychtoolbox, but I can't even get past showing my 3-line instructions on the screen with DrawFormattedText. This is my code:
% Set up the screen
clear all
close all
Screen('Preference','SkipSyncTests',1);
[win,screenRect]=Screen('OpenWindow',0,[127 127 127],[100 100 1000 800]);
% Instructions
tstring=["Blabla.\nBlabla.\nBlabla."];
[nx,ny]=DrawFormattedText(win,tstring,'center','center',[0 0 0]);
Screen('Flip',win)
% Close experiment
pause(3)
sca
However, when I try to run it, I get this error:
Index exceeds the number of array elements (1).
Error in DrawFormattedText (line 276)
tstring = [ tstring(1:min(newlinepos)-1) repchar tstring(min(newlinepos)+2:end)];
Error in Experiment (line 17)
[nx,ny]=DrawFormattedText(win,tstring,'center','center',[0 0 0]);

 採用された回答

Walter Roberson
Walter Roberson 2020 年 10 月 8 日

1 投票

tstring=["Blabla.\nBlabla.\nBlabla."];
Psychtoolbox was written before string objects existed. You will need to pass a character vector not a string object.

1 件のコメント

aptdando
aptdando 2020 年 10 月 8 日
Can't believe it was this simple! Thank you

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

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020b

質問済み:

2020 年 10 月 8 日

コメント済み:

2020 年 10 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by