- Community Home
- :
- Discussion Forums
- :
- Most Active Software Boards
- :
- LabVIEW
- :
- Matlab solve generated result, copy to labview fomula node

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

08-31-2012 03:10 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

- Tags:
- fomula node
- MATLAB

08-31-2012 05:17 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Even

_________________________________

Certified LabVIEW Associate Developer

Automated Test Developer

Topro AS

Norway

08-31-2012 08:13 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

08-31-2012 08:15 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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)

08-31-2012 08:43 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi muyu,

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

Best regards,

GerdW

CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO

Kudos are welcome

GerdW

CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO

Kudos are welcome

09-01-2012 12:30 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

09-02-2012 04:08 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO

Kudos are welcome

GerdW

CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO

Kudos are welcome