Old Matlab script not running on newer version

3 次查看(过去 30 天)
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 个评论
Adam
Adam 2019-10-4
编辑:Adam 2019-10-4
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 2019-10-4
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: .'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by