필터 지우기
필터 지우기

how to do wavwrite on this mat file

조회 수: 4 (최근 30일)
moonman
moonman 2011년 10월 31일
Hi i am having mat file which is having DTMF tones i am listening tones by this
x = load('dtmfsig.mat')
f = fieldnames(x)
soundsc(x.(f{1}), 8000)
Now i want to save this tone in a wave file
i know wavread command but how to use it here??
  댓글 수: 1
tammna abid
tammna abid 2012년 5월 9일
Hello there ,
i also have same problem , want to convert .mat file to .wav file with this code but unable to do so
x=load('read.mat');
wavwrite(x,8000,16,'foo.wav');
i also did the method mention below x.f{1} but of no help, pls help me out

댓글을 달려면 로그인하십시오.

채택된 답변

Wayne King
Wayne King 2011년 10월 31일
fieldnames() returns a cell array. So
f = fieldnames(x);
is returning the fieldnames of x in the cell array f
x.(f{1}) is addressing the field of x that is in the first element of that cell array.
Is that what you want to write? It might be x.(f{2}), etc. depending on how the structure array is formed.
  댓글 수: 2
Wayne King
Wayne King 2011년 10월 31일
For example (this is just my example!)
x = struct('Fs',8000,'data',randn(1e3,1));
f = fieldnames(x);
x.(f{1}) % this is 8000, the sampling frequency
plot(x.(f{2})); % is the data field (the signal)
% but
x = struct('data',randn(1e3,1),'Fs',8000);
f = fieldnames(x);
plot(x.(f{1})) % this is the signal
x.(f{2}) % this is the sampling frequency
tammna abid
tammna abid 2012년 5월 9일
what actually 'data' here above stand for ? means data of .mat file ?, i didnt get your example above

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Honglei Chen
Honglei Chen 2011년 10월 31일
To write a wave file, you need at least the signal and the sampling frequency. From you example, it seems you can just do
wavwrite(x.(f{1}),8000,'foo.wav')
where you can replace foo.wav to whatever the name you choose for your wav file.
HTH
  댓글 수: 1
tammna abid
tammna abid 2012년 5월 9일
Siri am having the same problem , pls figure it out where i am wrong
x=load('read.mat');
>> f=fieldnames(x);
>> wavwrite(x.(f{1}),8000,'foo.wav')
Warning: Data clipped during write to file:foo.wav
> In wavwrite>PCM_Quantize at 247
In wavwrite>write_wavedat at 267
In wavwrite at 112
>>
what these warning actually means ?

댓글을 달려면 로그인하십시오.


moonman
moonman 2011년 10월 31일
ok thanks can u kindly eexplain abt x.(f{1})
why 1 is there
  댓글 수: 2
Fangjun Jiang
Fangjun Jiang 2011년 10월 31일
It's in your code, man!
Fangjun Jiang
Fangjun Jiang 2011년 10월 31일
You are loading 'dtmfsig.mat'. x.(f{1}) will be the first (alphabetically) variable in the .mat file.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 AI for Signals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by