>> filename=('s2.wav');
>> y=wavread(filename);
>> [y,Fs,nbits]=wavread(filename);
>> save(filename,'-mat');
why save(filename,'-mat'); does not create the *.mat file?

 Respuesta aceptada

CS Researcher
CS Researcher el 4 de Mayo de 2016

0 votos

You should do this:
filename = 's2.wav';
[y, Fs] = audioread(filename);
save('s2.mat','y');

4 comentarios

Nor Ashikin
Nor Ashikin el 4 de Mayo de 2016
thanks for the answer. I managed to save it in the form of mat file. However when Im trying to load the mat file (using this command: load s2.mat;), the mat file does not appear in the workspace. May I know why? I have checked the mat file has data in it.
CS Researcher
CS Researcher el 4 de Mayo de 2016
It works fine on my system. Do you not get the variable y in the workspace after this command? Do you get any errors?
Walter Roberson
Walter Roberson el 4 de Mayo de 2016
mat files do not appear in workspaces. Variables appear in workspaces. But not if you are using a static workspace
Nor Ashikin
Nor Ashikin el 4 de Mayo de 2016
Thanks for your help CS Researcher and Walter Roberson as well. It worked actually. Just my mistake.

Iniciar sesión para comentar.

Más respuestas (2)

Walter Roberson
Walter Roberson el 4 de Mayo de 2016

0 votos

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 el 4 de Mayo de 2016

0 votos

Just use
save 'filename'

1 comentario

Walter Roberson
Walter Roberson el 4 de Mayo de 2016
That would create 'filename.mat' -- literally "filename", not 's2.mat'

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 4 de Mayo de 2016

Comentada:

el 4 de Mayo de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by