How to calculate a sum?

I have a sum S (the greek symbol) from p=0 to M-1, g=(Is/VT)*exp(x/VT); and I want: ans=1/M * sum(g*exp(-j*(2*pi/M)*p)). x is a 21x1 vector and i need an answer 21x21.
Please help!

Answers (1)

g=(Is/VT)*exp(x/VT);
1/M * sum(g * exp(-j*(2*pi/M).*(0:M-1)))
However, if x is a vector, you need to clarify what shape it is (row or column) and need to clarify whether you want matrix multiplication for the "g*exp" part or what you want to do if x is a vector.

6 Comments

P
P on 14 May 2011
X=21x1 double array.And my ans needs to be a matrix with 21 values
g=(Is/VT)*exp(x/VT);
1/M * sum(g * exp(-j*(2*pi/M).*(0:M-1)),2)
P
P on 14 May 2011
So for my algorithm this ans needs to agree with another matrix y=21x21 because I want to do ans+y.How can i do that? your result are are 1x21 vector. thx a lot walter!
P
P on 14 May 2011
srry the result is 21x1 vector but still i can't sum this with a 21x21 matrix
If your x is 21x1 then what I proposed will produce a 21x1 output, not a 1 x 21. For example, size(sum((1:21).' * (0:4),2)) yields 21 1
Are you expecting a 21x21 matrix of different values, or are you wanting to copy the 21x1 matrix out to 21x21 ? If you want to copy it out to 21x21 then
repmat(1/M * sum(g * exp(-j*(2*pi/M).*(0:M-1)),2),1,21)
if you want all the rows to be the same, or
repmat((1/M * sum(g * exp(-j*(2*pi/M).*(0:M-1)),2)).',21,1)
if you want all the columns to be the same
P
P on 14 May 2011
I was expecting 21x 21 different values because M=21 points(-10...0...10) . I was expecting something like that:
a(0) a(-1) a(-2)....
a(1) a(0) a(-1)....
a(2) a(1) a(0).....

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

P
P
on 14 May 2011

Community Treasure Hunt

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

Start Hunting!