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!

 採用された回答

Walter Roberson
Walter Roberson 2022 年 12 月 20 日

1 投票

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)

1 件のコメント

Szymon
Szymon 2022 年 12 月 20 日
That works, thank you very much :)

サインインしてコメントする。

その他の回答 (0 件)

製品

リリース

R2022b

質問済み:

2022 年 12 月 19 日

コメント済み:

2022 年 12 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by