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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by