Display numerical output with sprintf?

1 回表示 (過去 30 日間)
Chelsea
Chelsea 2014 年 11 月 19 日
コメント済み: Chelsea 2014 年 11 月 19 日
Hi,
I am creating a Psychtoolbox script where a subject completes button presses. The number of button presses he or she completes is defined as "numPresses". Later, I want to display that number (from earlier in the script). I think I use sprintf, but am not sure how to do it correctly. Below is my attempt. Thanks!
Screen(window,'FillRect',0);
Screen(window, 'Flip');
Screen(window, disp(sprintf('You completed %d key presses, numPresses.')), ceil(resX/2)-60, ceil(resY/2), 255);
Screen(window, 'Flip');
pause(2.0);
I have tried it with both "disp" and as "Screen(window, 'DrawText',sprintf...). The error I get is below...Error using disp Too many output arguments.
Error in effrtattempt (line 190)
Screen(window, disp(sprintf('You completed %d key presses, goalReachedCount.')), ceil(resX/2)-60, ceil(resY/2),
255);
Thanks!

採用された回答

Thorsten
Thorsten 2014 年 11 月 19 日
text = sprintf('You completed %d key presses.', numPresses);
Screen(window, 'DrawText', text, ceil(resX/2)-60, ceil(resY/2), 255);
  1 件のコメント
Chelsea
Chelsea 2014 年 11 月 19 日
Thanks so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by