I am getting error when i try to listen mat file

조회 수: 1 (최근 30일)
moonman
moonman 2011년 10월 31일
Hi i am having mat file its name is sig.mat it is having dtmf tones in it
i m using
x=load('sig.mat');
soundsc(x,8000)
and i am getting error
??? Undefined function or method 'min' for input arguments of type 'struct'.
Error in ==> soundsc at 27 xmin = min(x(:));

채택된 답변

Wayne King
Wayne King 2011년 10월 31일
Hi Moonman, what is x?
>>whos x
If it is a structure, then feed soundsc() the appropriate field
soundsc(x.data,8000)
or whatever the field is.
  댓글 수: 1
Wayne King
Wayne King 2011년 10월 31일
for example if you tried:
x = struct('data',randn(1e3,1));
soundsc(x,8000)
You would get that error. But
soundsc(x.data,8000)
is fine

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

추가 답변 (3개)

moonman
moonman 2011년 10월 31일
I am having a mat file and i want to listen it
now i am using this and still getting error
x=load('sig.mat');
soundsc(x.data,8000)
the whosx command returns
whos x
Name Size Bytes Class Attributes
x 1x1 28124 struct
  댓글 수: 1
Wayne King
Wayne King 2011년 10월 31일
enter fieldnames(x) and see what you really want to listen to
Please see my comment above:
for example if you tried:
x = struct('data',randn(1e3,1));
soundsc(x,8000)
You would get that error. But
soundsc(x.data,8000)
is fine

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


moonman
moonman 2011년 10월 31일
I am doing as per ur instructions now i did this but did not listen any sound
x = struct('data','dtmfsig.mat');
soundsc(x.data,8000)
  댓글 수: 1
Wayne King
Wayne King 2011년 10월 31일
That is not per my instructions. I was constructing a struct array as an example. You have entered:
x = load('sig.mat');
x is a structure array, you cannot play a structure array with soundsc(), you have to play a field of a structure array. Enter
fieldnames(x)
and see which part of x you really want to play.

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


Jan
Jan 2011년 10월 31일
It seems to be nothing but non-trivial. Let me try it also, Wayne:
x = load('sig.mat');
f = fieldnames(x);
fprintf('%s\n', f{:}); % Just for information
soundsc(x.(f{1}), 8000);

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by