Reputation: 1
I have a randomly generated vector, say A
of length M
.
Say:
A = rand(M,1)
And I also have a function, X(k) = sin(2*pi*k)
.
How would I find Y(k)
which is summation of A(l)*X(k-l)
as l
goes from 0 to M
?
Assume any value of k... But the answer should be summation of all M+1
terms.
Upvotes: 0
Views: 5527
Reputation: 5595
If you're trying to do a fourier transform, you should also look at fft.
Upvotes: 0
Reputation: 473
You may be looking for the convolution of the vectors A and X:
Y = conv(A, X);
Upvotes: 0
Reputation: 125854
Given M
and k
, this is how you can perform your summation:
A = rand(M+1,1); %# Create M+1 random values
Y = sin(2*pi*(k-(0:M)))*A; %# Use a matrix multiply to perform the summation
EDIT: You could even create a function for Y
that takes k
and A
as arguments:
Y = @(k,A) sin(2*pi*(k+1-(1:numel(A))))*A; %# An anonymous function
result = Y(k,A); %# Call the function Y
Upvotes: 2
Reputation: 8135
A = rand(1, M + 1);
X = sin(2 * pi * (k - (0 : M)));
total = sum(A .* X);
Upvotes: 0