How can I do sigma over functions

5 views (last 30 days)
srinath
srinath on 2 Jul 2013
Hi all,
Suppose if I know y(j) and z(j) (suppose j varies from 1 to 100) and there are two functions : which vary with x,y,z and with the value of j
f1(x,y,z,y1(j),z1(j)),f2(x,y,z,y1(j),z1(j)).
And if f3(x,y,z,y1(j),z1(j))=f1*f2.
How can I do do summation of f3 over j?
I should be left with a function of x,y,z after summation over j. Can some one please tell me in a sequential way?
Thank you,
Srinath

Answers (1)

Matt J
Matt J on 2 Jul 2013
Edited: Matt J on 2 Jul 2013
If your functions are vectorized and written to return column vectors, then it should be straightforward. For example,
yj=rand(100,1); %fake y(j)
zj=rand(100,1); %fake z(j)
f1=@(x,y,z) x+y+z+yj+zj;
f2=@(x,y,z) 2*(x+y+z).^2+yj.^2+zj.^2;
then
f3=@(x,y,z) sum(f1(x,y,z).*f2(x,y,z));
and you can then do things like,
>> f3(1,2,1)
ans =
1.6280e+04
  4 Comments
srinath
srinath on 5 Jul 2013
I didn't get what are those p(1),p(2),p(3). Also,what should I keep for the initial point. Because the solution that I finally get will depend on initial point right? Can you just elaborate that? Thanks again.
Matt J
Matt J on 5 Jul 2013
Edited: Matt J on 5 Jul 2013
p is a vector whose components p(1),p(2), and p(3) are your 3 unknowns. As you've been saying throughout, the quantities sum1, sum2, and sum3 depend on 3 unknown variables, so sum1(p(1), p(2), p(3)) is a way to express that in terms of a single unknown vector, p.
Yes, the solution could depend on the initial point if you have multiple solutions. In that case, you have to choose the initial guess based on approximate knowledge of where the particular solution you're looking for might lie. But that's always the burden in equation solving, when a symbolic solution of the equations is unavailable.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!