Old Matlab script not running on newer version

Hi,
I wonder if somebody could help.
I have a simple MATLAB 2007b script that I'd like to use with a newer version (I use 2016b now).
I did some changes myself, but I am not a programmer and the script does not work.
The messages I get are:
-------
1)
WARNING: This session of your experiment was run by you with the setting Screen('Preference', 'SkipSyncTests', 1).
WARNING: This means that some internal self-tests and calibrations were skipped. Your stimulus presentation timing
WARNING: may have been wrong. This is fine for development and debugging of your experiment, but for running the real
WARNING: study, please make sure to set Screen('Preference', 'SkipSyncTests', 0) for maximum accuracy and reliability.
ans =
Error using Screen
See error message printed above.
2)
Error using audiowrite
The value of 'filename' is invalid. Expected input to be one of these types:
char
Instead its type was double.
EDIT: long script text removed and uploaded as a file.

4 commentaires

Stephen23
Stephen23 le 4 Oct 2019
Modifié(e) : Stephen23 le 4 Oct 2019
It looks like you are using this third-party toolbox:
You should ensure that you have installed the most recent version.
It is possible that the toolbox does not work on the MATLAB version that you are using: the best people to contact for suport with that are the authors of that toolbox.
"Instead its type was double."
This might occur when a user returns from a UI without selecting a file, or the data was initialized but then never correctly set, or something similar. Use the debugging tools to identify where the numeric comes from.
Thank you Stephen,
I am using the latest psychotoolbox.
I got around the screen issue, but I am still stuck with the audiowrite.
I think the problem is that I replaced the old command wavwrite with audiowrite, but the line is the same:
wavwrite(transpose(recordedaudio), 8000, 16, strcat(subj_name,'/',num2str(block_num),'.wav'));
What the procedure should do, is to create a wav file everytime my participants in the experiment read a word aloud. Wav files should be progressively and automatically numbered in the "data" folder.
Do you have any idea how to resolve this problem?
Thanks!
R
Adam
Adam le 4 Oct 2019
Modifié(e) : Adam le 4 Oct 2019
I don't know what the parameters were for wavwrite, but
doc audiowrite
gives you the valid signatures for audiowrite.
The filename is the first argument, whereas in wavwrite it appears to have come at the end (this is why you get that particular error message - you are giving it y when it expects the filename). I assume the 'y' argument is your recordedaudio and the 8000 is Fs (sample frequency)? I don't know what the 16 represents though. There are a bunch of Name, Value pairs supported so if you know what the 16 is supposed to represent you may find it in those.
Guillaume
Guillaume le 4 Oct 2019
The 16 is the 'BitsPerSample' of audiowrite.

Connectez-vous pour commenter.

 Réponse acceptée

The equivalent of your wavwrite using audiowrite is:
audiowrite(fullfile(subj_name, sprintf('%d.wav', block_num)), recordedaudio.', 8000, 'BitsPerSample', 16);
Notes:
  • I've replaced the strcat by fullfile. fullfile is a better way of building paths.
  • I've replaced the num2str + string concatenation, by sprintf. It's a better way of constructing strings in my opinion.
  • I've replaced the transpose by its much shorter form: .'

1 commentaire

Fantastic! Thanks!
It works perfectly now.
Thanks all of you for your help!
Rob

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by