LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab solve generated result, copy to labview fomula node

Hi,

 

I have a fomula like this: 

 

Id = B*(Vg-Vt-0.5*Vd)Vd/(1+th1*(Vg-Vt))

 

and then I have three groups of (Vg, Id), as well as Vd value. What I want is the solution expression for Vt, B and th1.

 

I do not have Matlab so I asked my friend help to solve it for me. the command like the following:

 

>> syms Vd Vg1 Vg2 Vg3 Id1 Id2 Id3 th1 Vt B;
>> [th1,Vt,B]=solve('Id1=B*(Vg1-Vt-0.5*Vd)*Vd/ (1+ th1*(Vg1-Vt))','Id2=B*(Vg2-Vt-0.5*Vd)*Vd/ (1+ th1*(Vg2-Vt))','Id3=B*(Vg3-Vt-0.5*Vd)*Vd/ (1+ th1*(Vg3-Vt))','th1,Vt,B')

 

It works fine and I get the expressions. for example, Vt like the following:

 

Vt =

-.50000000000000000000000000000000*(2.*Vg1*Id3*Id2*Vg3-2.*Id2*Id1*Vg1*Vg3+2.*Id1*Vg3*Id2*Vg2+Id1*Vg1*Id2*Vd-1.*Id1*Vd*Id2*Vg2+Id1*Vd*Id3*Vg3-2.*Vg1*Id3*Id2*Vg2-1.*Id1*Vg1*Vd*Id3+Vd*Id3*Id2*Vg2-1.*Vd*Id3*Id2*Vg3-2.*Id1*Vg2*Id3*Vg3+2.*Id1*Vg1*Vg2*Id3)/(Id1*Id3*Vg3+Id1*Vg1*Id2-1.*Id1*Vg1*Id3-1.*Id1*Id2*Vg2+Id2*Vg2*Id3-1.*Id2*Id3*Vg3)

 

I copied this to the Labview fomula node, it runs without error. (for B and th1, I have to replace the "^" with "**"), but the results are not as expected. 

 

Do I have to change anything else before I copy to the fomula node? 

 

Appreciate if any someone can help me in this issue, or any other solutions for this in labview? Thank you. 

 

 

0 Kudos
Message 1 of 7
(3,197 Views)

Hi,

 

Can you show us the Matlab result and the LabVIEW result? You say the result is not as expected, what does that mean? I would say this probably has something to do with the syntax. Maybe LabVIEW expects "," instead of "." on the decimal numbers. Like 0,5 instead of 0.5. I'm not familiar with formula node, just making some guesses. 

 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 2 of 7
(3,182 Views)
hi Even, thanks for the reply. actually the following Vt is part of the Matlab result. The B and th1 is too long to display here. I just copy the it to the formula node with necessary input and run. The only thing I changed is replace the "^" with "**", as in labview "^" means exclusive or, not power. I just wonder anything else need to be changed. Vt = -.50000000000000000000000000000000*(2.*Vg1*Id3*Id2*Vg3-2.*Id2*Id1*Vg1*Vg3+2.*Id1*Vg3*Id2*Vg2+Id1*Vg1*Id2*Vd-1.*Id1*Vd*Id2*Vg2+Id1*Vd*Id3*Vg3-2.*Vg1*Id3*Id2*Vg2-1.*Id1*Vg1*Vd*Id3+Vd*Id3*Id2*Vg2-1.*Vd*Id3*Id2*Vg3-2.*Id1*Vg2*Id3*Vg3+2.*Id1*Vg1*Vg2*Id3)/(Id1*Id3*Vg3+Id1*Vg1*Id2-1.*Id1*Vg1*Id3-1.*Id1*Id2*Vg2+Id2*Vg2*Id3-1.*Id2*Id3*Vg3)
0 Kudos
Message 3 of 7
(3,176 Views)

hi Even,

 

thanks for the reply.

 

actually the following Vt is part of the Matlab result. The B and th1 is too long to display here. I just copy them to the formula node with necessary inputs and run. The only thing I changed is replace the "^" with "**", as in labview "^" means exclusive or, not power.

 

I just wonder anything else need to be changed.

 

Vt =

 

-.50000000000000000000000000000000*(2.*Vg1*Id3*Id2*Vg3-2.*Id2*Id1*Vg1*Vg3+2.*Id1*Vg3*Id2*Vg2+Id1*Vg1*Id2*Vd-1.*Id1*Vd*Id2*Vg2+Id1*Vd*Id3*Vg3-2.*Vg1*Id3*Id2*Vg2-1.*Id1*Vg1*Vd*Id3+Vd*Id3*Id2*Vg2-1.*Vd*Id3*Id2*Vg3-2.*Id1*Vg2*Id3*Vg3+2.*Id1*Vg1*Vg2*Id3)/(Id1*Id3*Vg3+Id1*Vg1*Id2-1.*Id1*Vg1*Id3-1.*Id1*Id2*Vg2+Id2*Vg2*Id3-1.*Id2*Id3*Vg3)

0 Kudos
Message 4 of 7
(3,173 Views)

Hi muyu,

 

don't you think attaching the VI instead of that very long formula text would be more helpful?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(3,170 Views)

Hi, 

 

please check the attachment. It is actually a way of Vt calculation model called MM9. 

 

I've checked with some data from customers, it seems the calculation is correct. (I need to confirm this with them again). 

 

Thank you all. 

 

regards, 

 

muyuqiao

0 Kudos
Message 6 of 7
(3,149 Views)

Hi muyu,

 

"it seems the calculation is correct."

Whenever I have to use formulas that are several screens wide when written I really appreciate to apply some basic math rules and to split those formulas into it's terms. Then I can (much easier) check the output of each term and it will be much easier too to convert those formulas into real G code!

 

It usually doesn't help to write "0.5" with ~30 digits when DBL datatype is used: DBL can only handle ~17 digits!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(3,142 Views)