sir i tried one code for framing and windowing but the code showing error like this Error in lpcoefficient (line 21) wind(i,:)=​fr_ws(i,:)​.*r(i,:); how i rectify the error

5 ビュー (過去 30 日間)
the code is given below,
[x,fs]=audioread('1calf.wav');
s = x(1:93098,:);
N=length(s);
frameduration=0.00475;
framelength=frameduration*fs;
num_frames=floor(N/framelength);
count=0;
for k= 1: num_frames
frames(k,:)=s((k-1)*framelength +1 : framelength*k);
count=count +1;
end
m_amp = abs(max(frames,[],2)); % find maximum of each frame
id = find(m_amp > 0.06); % finding ID of frames with max amp > 0.03
fr_ws = frames(id,:); % frames without silence
for i=1:num_frames
v=length(fr_ws);
r=hamming(v);
wind(i,:)=fr_ws(i,:).*r(i,:);
end
  2 件のコメント
KSSV
KSSV 2019 年 5 月 9 日
What error? Without specifying error and without input data, how you think you will get help?
Suchithra K S
Suchithra K S 2019 年 5 月 9 日
the error is like this "Index exceeds matrix dimensions.
Error in lpcoefficient (line 21)
wind(i,:)=fr_ws(i,:).*r(i,:);

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

回答 (1 件)

Jan
Jan 2019 年 5 月 9 日
編集済み: Jan 2019 年 5 月 9 日
One hint: In
for i=1:num_frames
v=length(fr_ws);
r=hamming(v);
wind(i,:)=fr_ws(i,:).*r(i,:);
end
v and r are constant. Then move the definition out of the loop to avoid a repeated computation. Maybe wind has the wrong size, because it is not pre-allocated - postinmg the error message would reveal this detail, so share this important message with the readers. Then:
v = length(fr_ws);
r = hamming(v);
wind = zeros(num_frames, v);
for i = 1:num_frames
wind(i,:) = fr_ws(i,:) .* r(i,:);
end
Now r(i, :) is a scalar. Is this wanted, or do you mean:
for i = 1:num_frames
wind(i,:) = fr_ws(i,:) .* r.';
end
I guess, you can omit the loop completely using the modern auto-expanding:
wind = fr_ws .* r.';
  7 件のコメント
Jan
Jan 2019 年 5 月 10 日
@Suchithra K S: As soon as you use the debugger and post, what
size(wind)
size(fr_ws)
size(r)
replies, I could post a working solution. Maybe you need:
% R2016a - no auto-expanding:
wind = bsxfun(@times, fr_ws, r.');
Suchithra K S
Suchithra K S 2019 年 5 月 14 日
I tried the above to my code at that time also it showing error
Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
Error in lpcoefficient (line 24)
wind = bsxfun(@times, fr_ws, r.');
How to rectify this error?

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

カテゴリ

Help Center および File ExchangeEarth and Planetary Science についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by