Symbolic Differentiation and Then Numeric Calculation for Multiple Arrays

조회 수: 1 (최근 30일)
Burak Duran
Burak Duran 2020년 6월 30일
편집: darova 2020년 7월 1일
Dear All,
I have two different arrays; F(1x4), d(1x8). d matrice is actually consisted of two sub matrices d1(1x4) and d2(1x4). I mean d=[d1;d2
My pupose is to write a symbolic function. I know that maybe the funciton should be out of a loop, but I can't understand how can I handle this.
Actually, my function is like g(F,d)=F-500*d1*d2 and then I want to take differentiation of this function according to d1 and d2. Next, give the numeric value coming from F and d arrays for i'th iteration. So, get numeric after conversion.
d is like that [d1 d2 d1 d2 d1 d2 d1 d2]
How can I express such a function symbolic, take differentiation and then put the numeric values for that loop coming from F and d matrices.
Example;
g(F,d)=F(i)-500*d(2*i-1)*d(2*i+1)
diff(g,d(2*i-1))=-500*d(2*i+1)
for i=1
g1_Numeric(1)=double(g1(F(1),d(1),d(2)))
Written code is like as follow;
for i=1:4
syms g(F,d1,d2)
g(F,d)=F(i)-500*d(2*i-1)*d(2*i+1)
g1=-((diff(g,d(2*i-1))
g1_Numeric(i)=double(g1(F(i),d(2*i-1),d(2*i+1)))
g2=-((diff(g,d(2*i+1))
g2_Numeric(i)=double(g2(F(i),d(2*i-1),d(2*i+1)))
end
Thanks,
Burak

답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by