Hello,
Need Help to translate short code from Matlab to VB6,
the code contain numerical computing, Gradient and Hessian Matrix.
Regards,
Maritime
Printable View
Hello,
Need Help to translate short code from Matlab to VB6,
the code contain numerical computing, Gradient and Hessian Matrix.
Regards,
Maritime
What is the code that needs translating?
Hello,
ML(1, 1) = 3.27419030768864
ML(1, 2) = 1.67217103086368
ML(1, 3) = 0.77642827451032
ML(2, 1) = 1.67217103086368
ML(2, 2) = 1.56451953051059
ML(2, 3) = 1.22506096105216
ML(3, 1) = 0.77642827451032
ML(3, 2) = 1.22506096105216
ML(3, 3) = 3.48985429950068
VL(1) = 2.84044604335216
VL(2) = 2.09345971197122
VL(3) = 3.15558646083793
I need to translate this pat of code:
Code:
while (norm(dF,2)>=1e-12)&(m<1000)
S=dot(Vi,Vi)-1;
dF=2*(ML+2*b*S*eye(3,3))*Vi-2*VL
ddF=2*(ML+2*b*S*eye(3,3))+8*b*(Vi*Vi')
m=m+1
dV=-inv(ddF)*dF
Vi=Vi+dV
end
This is result from matlab:
donc ta matrice ML c'est celle la
ML =
3.274190307688642 1.672171030863679 0.776428274510320
1.672171030863679 1.564519530510586 1.225060961052163
0.776428274510320 1.225060961052163 3.489854299500683
>> VL
VL =
2.840446043352157
2.093459711971220
3.155586460837926
V0
Vi =
1
1
1
le b
b=
4.328564137699911
In this loop we do S, dF, ddF
S=dot(Vi,Vi)-1;
dF=2*(ML+2*b*S*eye(3,3))*Vi-2*VL
ddF=2*(ML+2*b*S*eye(3,3))+8*b*(Vi*Vi')
at the first itération:
S =
2
dF =
40.393200241020260
39.365096722509705
39.300027250049766
ddF =
75.805406818575861 37.972855163326649 36.181369650619928
37.972855163326649 72.386065264219752 37.078635023703612
36.181369650619928 37.078635023703612 76.236734802199948
donc le Vi que tu retrouves c'est
Vi =
0.722525144159246
0.731431659439092
0.746808943305029
et le dV
>> dV
dV =
-0.277474855840754
-0.268568340560908
-0.253191056694971
le Vi final vaut
Vi =
0.670836406672209
0.041286954641636
0.740460615214353
done after 12 iterations proximately,
I am sorry for the comments in French !
Regards,
Maritime