Invalid expression, Correlation Analysis

N = length(data);
Mlen=256;
Mstep=192;
Nramek=floor((N-Mlen)/Mstep+1);
ramki = zeros(Mlen, Nramek);
Xr = zeros(Mlen * 2 - 1, Nramek);
for i=0:Nramek-1
ramki(:, i+1) = data(1 + i*Mstep : i*Mstep + Mlen);
ramki(:, i+1) = ramki(:,i+1) - mean(ramki(:, i+1));
[Xr(:,i+1), lags] = xcorr(ramki(:, i+1));
end
offset = 20;
[XrMax, idxMax] = max(Xr(lags > offset,:));
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
idxVoiced = XrMax > 0.35*Xr(lags == 0);
lags = lags(lags > offset);
lags = lags(idxMax(idxVoiced));
T = mean(lags) / Fs;
fpod = Fs/mean(lags)
I have question, why this code does not work? I have been thinking about this problem for hours and have no idea :(
Thank for help!

 Accepted Answer

You appear to have copied from a source that used HTML entity encoding, You need to rewrite the operators
N = length(data);
Mlen=256;
Mstep=192;
Nramek=floor((N-Mlen)/Mstep+1);
ramki = zeros(Mlen, Nramek);
Xr = zeros(Mlen * 2 - 1, Nramek);
for i=0:Nramek-1
ramki(:, i+1) = data(1 + i*Mstep : i*Mstep + Mlen);
ramki(:, i+1) = ramki(:,i+1) - mean(ramki(:, i+1));
[Xr(:,i+1), lags] = xcorr(ramki(:, i+1));
end
offset = 20;
[XrMax, idxMax] = max(Xr(lags > offset,:));
idxVoiced = XrMax > 0.35*Xr(lags == 0);
lags = lags(lags > offset);
lags = lags(idxMax(idxVoiced));
T = mean(lags) / Fs;
fpod = Fs/mean(lags)

More Answers (0)

Products

Release

R2022b

Asked:

on 19 Dec 2022

Commented:

on 20 Dec 2022

Community Treasure Hunt

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

Start Hunting!