views:

70

answers:

1
B=[1 1 1 1 1 1....1] % vector of length N elements

Xk= sin(2*pi/16) 

i need to find function alpha(l,k) which is having two variables l and k and a condition given that alpha(l,0)=alpha(l,-1)=alpha(l,-2)......=alpha(l,-(N-1))=0 i.e no matter what value of l ,alpha = 0 for past values

A= input('no of iterations'); % no. of iterations user want
N=input('N values of alpha:')
alpha1=[];

for k=0:A-1

l=0:N-1    % need 10 separate alpha values for every k, which goes from 0 to A-1 

alpha(l,k)= Xk + summation( B(j)*alpha(l,k-j)) % as summation goes from j=1 to N


alpha1=[alpha1 alpha]

end;

could anyone please help me to solve this recursive function, i am new to matlab.

alpha

A: 

As I read the question the answer basically should look like this:

function x=alpha(l,k)
if k<=0
  x=0;
  return
else
  % from your code
  x = Xk + summation( B(j)*alpha(l,k-j)) % as summation goes from j=1 to N
end

Of course you need to add the declarations in the function...

decaf

related questions