0

It would be brilliant if someone could help with this.

I've got a list of words in a .txt file in a single column, and want to present them in a random order (without replacement) using DrawFormattedText in Matlab Psychtoolbox.

At the moment I'm getting this error:

Error using cast
Unsupported class for conversion.

Error in DrawFormattedText (line 282)
        curstring = cast(curstring, stringclass);
H.Muster
  • 9,297
  • 1
  • 35
  • 46
  • 2
    You're much more likely to get help if you provide some context for that error. What chunk of your code throws that error? What's the simplest possible version of your program that will produce the same error? – Isaac Sep 14 '12 at 17:42
  • This extract produces the same error: – user1671947 Sep 17 '12 at 09:02
  • MedicineInformation='MedicineInfo.txt'; [Word]=textscan(MedicineInformation, '%s'); Information=Word{1}; InformationText=RandSample(Information); DrawFormattedText(w,InformationText,'center','center'); – user1671947 Sep 17 '12 at 09:09

1 Answers1

0

I am not experienced with the psych toolbox, but the task you describe seems quite straightforward.

Here is how I would approach it:

  • Try to import the file by locating it in your current directory, rightclicking it and selecting "import data"

Hopefully your data is structured nicely, otherwise you may need to be more creative.

  • You will now get a variable, for example 'data', a Nx1 cell array

  • Now you can draw randomly by means of: p = randperm(1:N)

If you want to show 100 words, just do:

for i = 1:100
data(p(i))
end
Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122