cannot create mat file.

2 次查看(过去 30 天)
>> filename=('s2.wav');
>> y=wavread(filename);
>> [y,Fs,nbits]=wavread(filename);
>> save(filename,'-mat');
why save(filename,'-mat'); does not create the *.mat file?

采纳的回答

CS Researcher
CS Researcher 2016-5-4
You should do this:
filename = 's2.wav';
[y, Fs] = audioread(filename);
save('s2.mat','y');
  4 个评论
Walter Roberson
Walter Roberson 2016-5-4
mat files do not appear in workspaces. Variables appear in workspaces. But not if you are using a static workspace
Nor Ashikin
Nor Ashikin 2016-5-4
Thanks for your help CS Researcher and Walter Roberson as well. It worked actually. Just my mistake.

请先登录,再进行评论。

更多回答(2 个)

Walter Roberson
Walter Roberson 2016-5-4
save() is not defined to override your choice of file extensions. If a file already has an extension, then save() will use that extension. So what you are doing is overwriting your .wav file with the mat contents.
If you want to change the extension, then use fileparts to extract the file name without the extension; when there is no extension, .mat will be added.

MHN
MHN 2016-5-4
Just use
save 'filename'
  1 个评论
Walter Roberson
Walter Roberson 2016-5-4
That would create 'filename.mat' -- literally "filename", not 's2.mat'

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by