Parse Error at '['

3 views (last 30 days)
Abhiraj Kanse
Abhiraj Kanse on 22 May 2018
Commented: Guillaume on 22 May 2018
function [fdly,tdly] = audio(sig1,sig2)
i = 1;
j = 1;
fdly = zeros(1,266);
tdly = zeros(1,266);
while (i <= 12768000)
a = sig1(i:48000);
b = sig2(i:48000);
[cor,lag] = xcorr(a,b,'coeff');
[~,Il] = max(abs(cor));
fdly(j) = lag(Il);
tdly(j) = fdly(j)/48000;
i = i+48000;
j = j+1;
end
end
*[* sp1,fs1] = audioread('F:\Moodle\Summer18\sync porject\iitb recordings\01_SPK1_05_06_2017-09.wav');
I am getting parse error at the marked bracket, I don't know why!
  2 Comments
Jos (10584)
Jos (10584) on 22 May 2018
Please copy the exact error message you get.
Guillaume
Guillaume on 22 May 2018
Please post (or attach as a m file) the exact code you're using. Without any modification. Also post the full text of the error message.
You've given us conflicting versions of your code. With this particular error, the problem is from what comes before the [.

Sign in to comment.

Answers (1)

KSSV
KSSV on 22 May 2018
[sp1,fs1] = audioread('F:\Moodle\Summer18\sync porject\iitb recordings\01_SPK1_05_06_2017-09.wav');
There should be no stars, in the first place. And this line should be copied above your function audio not, after the function.
  3 Comments
Abhiraj Kanse
Abhiraj Kanse on 22 May 2018
[sp1,fs1] = audioread('F:\Moodle\Summer18\sync porject\iitb recordings\01_SPK1_05_06_2017-09.wav');
[ar1,fs4] = audioread('F:\Moodle\Summer18\sync porject\iitb recordings\04_ARRAY1_05_06_2017-09.wav');
ar11 = ar1.*(100);
function [fdly,tdly] = delaycalc(sig1,sig2)
i = 1;
j = 1;
fdly = zeros(1,266);
tdly = zeros(1,266);
while (i <= 12768000)
a = sig1(i:48000);
b = sig2(i:48000);
[cor,lag] = xcorr(a,b,'coeff');
[~,Il] = max(abs(cor));
lagdly = lag(Il);
tmdly = lagdly/48000;
i = i+48000;
j = j+1;
display(tmdly)
display(lagdly)
end
Now it shows this error: Line 5: FUNCTION keyword use is invalid here. This might cause later message about END. Line 5: Parse error at ']': usage might be invalid MATLAB syntax
Line 5: Parse error at ')': usage might be invalid MATLAB syntax
KSSV
KSSV on 22 May 2018
Save this code first, defualt this will be saved on the name delaycalc. Save this in some folder.
function [fdly,tdly] = delaycalc(sig1,sig2)
i = 1;
j = 1;
fdly = zeros(1,266);
tdly = zeros(1,266);
while (i <= 12768000)
a = sig1(i:48000);
b = sig2(i:48000);
[cor,lag] = xcorr(a,b,'coeff');
[~,Il] = max(abs(cor));
lagdly = lag(Il);
tmdly = lagdly/48000;
i = i+48000;
j = j+1;
display(tmdly)
display(lagdly)
end
And then, change the path, and go to that folder. Now, you can call that function.
[sp1,fs1] = audioread('F:\Moodle\Summer18\sync porject\iitb recordings\01_SPK1_05_06_2017-09.wav');
[fdly,tdly] = delaycalc(sp1,fs1)

Sign in to comment.

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

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

Start Hunting!