How can I do sigma over functions
이전 댓글 표시
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
답변 (1개)
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
Matt J
2013년 7월 3일
F=@(p) [sum1(p(1),p(2),p(3));...
sum2(p(1),p(2),p(3));...
sum3(p(1),p(2),p(3))];
fsolve(F,initialpoint);
srinath
2013년 7월 5일
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.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!