Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: help in matlab program
Replies: 1   Last Post: Nov 16, 2013 2:11 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
emro87

Posts: 4
Registered: 11/14/13
help in matlab program
Posted: Nov 14, 2013 6:14 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi.. i am struggling with a problem in matlab that i dont know how to solve, i will be glad if you can help.
-the main cod is:

[data,Fs]=wavread('my_123.wav');
N=length(data);

L=160; % L/Fs=20ms
M=fix(N/L);
start=1;
stop=L;
En(1)=0
x=zeros(L);
for m=0:(M-1)
x=data(start:stop);
E=energyFunc(x,m,L);

En(m+2)=En(m+1)+E;
start=start+160;
stop=stop+160;

end

-and thats the function code:

function [ D ] = energyFunc( x,m,L )

D=0;
for n=1:L
E=(1/L)*((x(n+m*L)).^2);
D=D+E;
end

end

-I get this error message:

Attempted to access x(161); index out of bounds because
numel(x)=160.

Error in energyFunc (line 6)
E=(1/L)*((x(n+m*L)));

Error in DSPmatlab1 (line 22)
E=energyFunc(x,m,L);

-I dont understand why its out of bounds? i configured the `for` loop from 1 to 160, so `x` should have been in range?
thanks.


Date Subject Author
11/14/13
Read help in matlab program
emro87
11/16/13
Read Re: help in matlab program
emro87

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.