eval function in matlab

Status
Not open for further replies.

sana_akhtar

Member level 2
Joined
Apr 21, 2012
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,606
I am a beginner in MATLAB coding. I was reading a code which I got from net about speech recognition. The .m file in which audio wave is loading has the code like this

clc;
name=['S5T0','S5T1','S6T0','S6T1','S7T0','S7T1','S8T0','S8T1','S9T0','S9T1']; %
digit=['0123456789']; %

for d=1:length(digit)
eval(['x=wavread(''ti_0',digit(d),'apple01.wav.wav'');']);
for k=1:4:length(name)
[x1 x2]=vadnew(x);
eval(['ti_0',digit(d),'F3',name(k:k+3),'=x(100*x1:100*x2);']);
%ti_00F3S0T0=wavread('x(1).wav');
x=x(x2*100:length(x));
end
end
save ('F3new.mat', 'ti*');

Can someone please tell me what is this line eval(['x=wavread(''ti_0',digit(d),'apple01.wav.wav'');']); is doing??
 

eval takes a string, and processes it as a matlab command.

in this case, assume d = 1.
['x=wavread(''ti_0',digit(d),'apple01.wav.wav'');']
becomes the string:
x=wavread(''ti_01apple01.wav.wav'');
and eval will run that matlab command, reading the samples from that file into a vector called "x".
if d = 2 then you get:
x=wavread(''ti_02apple01.wav.wav'');
etc...
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…