0

I'm looking for a way to print the value of a variable to the screen in Psychtoolbox (Matlab). I'm looking for something like fprintf: eg. fprintf('%s%d\n','Your score: ', score);

I'm guessing that DrawFormattedText() is the function I'm looking for, but can someone advise how to add a variable that isn't a part of the string?

Thanks.

codeaviator
  • 2,545
  • 17
  • 42
lharley
  • 21
  • 3

1 Answers1

0

Use sprintf to format data into a string and then pass that string to the DrawFormattedText function from the Psychtoolbox like this:

score = rand;    % Random score value.
DrawFormattedText(win, sprintf('Your score: %d\n', score));
codeaviator
  • 2,545
  • 17
  • 42