Old Matlab script not running on newer version

4 views (last 30 days)
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 Comments
Adam
Adam on 4 Oct 2019
Edited: Adam on 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 on 4 Oct 2019
The 16 is the 'BitsPerSample' of audiowrite.

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 4 Oct 2019
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 Comment
Roberto Filippi
Roberto Filippi on 4 Oct 2019
Fantastic! Thanks!
It works perfectly now.
Thanks all of you for your help!
Rob

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!