implementing this equation in matlab

Status
Not open for further replies.

serhannn

Member level 4
I have to implement the following equation in matlab.. I am trying to do it using a for-loop but I get an error since the initial value of L=0.
How else can I implement it?

The equation is:
The code I'm using and getting an error:
Code:
for i=1:L
delta = s(k) - lambda_prev(1+i)*(s(k-i))';
end

enjunear

As long as you aren't calling or assigning to an array element zero, like s(0)... then your code should work.

Additionally, you could shift everything by 1, making the loop run 0 to L, but where ever you have "i", change it to "i+1", so the first time through the loop you'll always have i+1 give you a 1, and not a 0.

Without seeing more of your code, its tough to say which method will work best for your situation.

Status
Not open for further replies.