Index exceeds matrix dimensions at buffer function

Here is what i'm gona trying to do :
  1. I read a .wav file called tes.wav stored in y
  2. I try performing 3-level Haar Wavelet Transform on it
  3. I try to framing the D3 (detail subband level 3)
So i have this following code :
f=wavread('tes.wav','native');
v=[1/sqrt(2) 1/sqrt(2)];
w=[1/sqrt(2) -1/sqrt(2)];
if mod(length(f),2)~=0
f=[f 0];
end
d=length(f);
m=1:d/2;
a1=f(2*m-1).*v(1) + f(2*m).*v(2);
d1=f(2*m-1).*w(1) + f(2*m).*w(2);
d=length(a1);
m=1:d/2;
a2=a1(2*m-1).*v(1) + a1(2*m).*v(2);
d2=d1(2*m-1).*w(1) + a1(2*m).*w(2);
d=length(a2);
m=1:d/2;
a3=a2(2*m-1).*v(1) + a2(2*m).*v(2);
d3=d2(2*m-1).*w(1) + a2(2*m).*w(2);
x=d3(1:length(d3),1);
frame=buffer(x,10);
But i Keep getting error message like this :
??? Index exceeds matrix dimensions.
Error in ==> Project at 32 x=d3(1:length(d3),1);

 채택된 답변

per isakson
per isakson 2013년 2월 28일
편집: per isakson 2013년 2월 28일

1 개 추천

Add the line
size( d3 )
before the line that errors. What does it show? (I guess d3 doesn't have the size you expect.)
Why do you use
x = d3( 1:length(d3), 1 );
and not
x = d3( :, 1 );
?
The error message indicates that the rows of d3 has more elements than the columns.

댓글 수: 3

I Made
I Made 2013년 2월 28일
편집: I Made 2013년 2월 28일
Yeah you are right, i've just saw the error now. the size of the d3 is just not like i expected. Thanks isakson for your reply. Anyway are you fammiliar with haar transform? i want to ask some more that i found d3 not like i expected.
the raw signal was < 250608x2 int16 > but after i process it become like a1 < 1x125304 int16 > and d1 < 1x125304 int16 >, what i expected is like a1 < 125304x1 int16 > ? do you know how i can achieve this?
Why is that change from 250608x2 become 1x125304 anyway. m x n, m = number of sample and n=number of chanel right? why does it's change position?
No, I'm not. However, searching the File Exchange for "haar transform" returned 18 contributions. Many of them with high ratings.
You could open a new question in Answers.
I Made
I Made 2013년 2월 28일
Yeah, anyway i got the code above there too. But when i add somemore code to framing it just dont working because the size change after the transform. Anyway thanks for your reply

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Shashank Prasanna
Shashank Prasanna 2013년 2월 27일
편집: Shashank Prasanna 2013년 2월 27일

0 개 추천

>> clear
and start fresh, There could be a conflict in the name of the variable vs name of the function

댓글 수: 2

Yeah; looks like length() was shadowed.
which -all length
Thanks for your reply, by the way where should i put the "clear all" or "clear" code? i've tried use it before
x=d3(1:length(d3),1);
frame=buffer(x,10);
But i got another error :
??? Reference to a cleared variable d3.
Error in ==> haarTransform at 34

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Discrete Multiresolution Analysis에 대해 자세히 알아보기

질문:

2013년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by