Solving nonlinear equation with VI

Hi,
I want to use LabView to solve a nonlinear equation. I read forums and figured out that I can use Nonlinear System Solver. vi and I noticed there are two options to write the equation: 1) F(X) is formula and 2) F(X) is VI. I could use the first option and write the equation with that but I did not understand how to use a sub-Vi to provide the equation. Would any one please tell me how to do that?
Thank you 

Soran,
Read the detailed help for the solver VI. 
The VI usually executes much faster than the formula parser/evaluator. Since solvers (and curve fitters, which have the same options) may need to evaluate the function many times while solving, that time can become significant.
In the help is a link to a template for the VI you need. You must use the exact connector pane and reference type. While you can create your own VI, it is much easier to use the template. On the block diagram create the code to generate your equation values in the configuration required by the solver. Be careful to put the parameters in the correcto order.
Lynn

Similar Messages

  • How do I solve simultaneous equation with 3 unknowns ?

    I need to solve simultaneous equations with 3 unknowns . Can any body help out on how to go about this? Thanx.

    You did not specify what kind of equations you have....
    Are your equations linear? Check the linear algebra palette and a look at "solve linear equations:.
    LabVIEW Champion . Do more with less code and in less time .

  • Solving an equation with a factorial in

    If I wanted to perform a calculation like, to find y,
    y = 1 + x + (x^2/2) + (x^3/6) + (x^4/24) + ........ (x^n/n!)
    And I enter values for n, I'm thinking I should use the 'for' rule.
    I can see how I get the numbers seperately but cannot see how I can 'integrate them together into a formula. Thanks. Matt

    I was trying VERY hard not to piss anyone off by
    posting the full solution so I was just showinghow
    to get the NUMBERS and not how to use them.
    There's no pleasing you guys is there. I meanit's
    like you want me to just post the answer.I don't get this Norweed.
    Why don't you post complete homework solutions? I
    thought you were convinced that it helped the student
    in question instead of giving hints and letting
    him/her do some thinking of their own.
    Are you not doing it anymore because of what others
    think of such actions? Or have you changed your
    opinion on the matter?
    PS. Just curious, I'm not saying you should post
    complete solutions!I never said that a full solution was always the best way to go. Just sometimes.

  • System calibration as a solution of nonlinear equations

    Good day,
    The challenge of the day is to provide a calibration for an accelerometer output, expressed as a binary value.
    I have an accelerometer whose operating range can be set (±2g, ±4g, ±8g).  The accelerometer itself then generates a binary value at 16bit resolution.  Hence, that 2^16 value (0-65535) represents an acceleration whose value depends on the ranges we set.
    So, we make the asumption that the response is linear, allowing us to claim:
    Acceleration = Scale x Binary Value + Offset
    I have three axes worth of data, accelerometer A, B and C.  If I hold the accelerometer stationary, the only thing I should be reading is the accleration due to gravity, g.  This gets me the relationship
    (A)^2 + (B)^2 + (C)^2 = g^2
    since, in any orientation, the magnitude of the combination of all three acceleration readings should be the acceleration due to gravity (and that shouldn't change no matter which way you happen to be pointing the accelerometer).
    What this gives me, then, is a nonlinear relationship of 6 variables (three scale factors and three offsets). I should be able to take six measurements in arbitrary orientations, which will give me six output values of each acclerometer.  I should then be able to pull out the scale factors and offsets for each accelerometer, either in terms of g or relating to what I think g is.
    My question, then, is how can I get Labview to do this?  I'm see that there's a Solve Linear Equations tool, but I'm not seeing one appropriate for the nonlinear case.  I'm also quite comfortable believing I'm just missing it :-)
    Thanks!
    Solved!
    Go to Solution.

    OK, so I've dug a bit deeper and believe that the Nonlinear System Solver is the appropriate starting point, as found in the example file Equation Explorer.vi.
    In that example, I can define a system of nonlinear equations and the vi should spit out the solutions (zeros) of the variables.  I got it to work with some arbitrary test data generated through excel.
    Now, I'm moving on to the next level of complexity in the model, and have derailed m'self again..
    The simulated device:
    a three axis accelerometer, each of which would generate an output of the form Voltage = Scale * Acceleration + Offset. 
    In a perfect world, the only accleration I'll be seeing is gravity (9.8 m/s^2), and I set that gravity in a random direction (indicating the accelerometer is at an arbitrary orientation).  Knowing that orientation, I then calculated what the components of the acceleration would be along all three axes, and then applied values for Scale and Offet to deterine what the equivalent voltage reading off the accelerometers would be.
    So now I start the long way home again.  From a Labview perspective, I know that I have three voltage outputs which would feed into a known relationship
    ((Vx - OffsetX)/ScaleX)^2 + ((Vy - OffsetY)/ScaleY)^2 + ((Vz - OffsetZ)/ScaleZ)^2 - 96.04 = 0
    where the 96.04 comes from g^2.  This is my nonlinear equation with six unknowns in it and three constants.
    Since I have six unknowns, I need six equations, which I can get by rerunning my simulation, right? 
    I put six generated "voltages" (Vx, Vy, Vz) into this form using my expected values for Scale and Offset, and run the vi. However, the vi returns nothing.  I know there should be a solution vecotr, because that's what I used to created the simulated data.  Is there something I'm overlooking?
    Attachments:
    Calibration.png ‏74 KB

  • Solving a system of nonlinear equations

    Hey guys,
    I am currently trying to solve a set of nonlinear equations in LabView with the help of MathScript and MATLAB code. I'm trying to create a working code since hours, but I haven't achieved this goal yet.
    System of equations:
    x^2 + y^2 + z^2 - R1^2 == 0
    x^2 + (y-Y0)^2 + z^2 - R2^2 == 0
    (x-X0)^2 + y^2 + z^2 - R3^2 == 0
    R1, R2, R3, X0, Y0 are known.
    Possible solution in MATLAB (assuming X0 = Y0 = 100, R1^2 = R3^2 = 11000, R2^2= 9000):
    Create myfun.m with content:
    function F = myfun(x);
    F = [x(1)^2 + x(2)^2 + x(3)^2 - 11000;
    x(1)^2 + (x(2)-100)^2 + x(3)^2 - 9000;
    (x(1)-100)^2 + x(2)^2 + x(3)^2 - 11000];
    end
    Set intial value for iteration:
    x0 = [50 50 50]
    Solve:
    fsolve(@myfun, x0)
    => Works fine!
    Now I tried to just plug all of this stuff into a MathScript Node:
    function F = myfun(x);
    F = [x(1)^2 + x(2)^2 + x(3)^2 - 11000;
    x(1)^2 + (x(2)-100)^2 + x(3)^2 - 9000;
    (x(1)-100)^2 + x(2)^2 + x(3)^2 - 11000];
    x0 = [50 50 50];
    Sol = fsolve(@myfun, x0);
    This is where the problem starts.
    When I try to run the program, I get the follwing error message:
    A function is defined in this script. You must save and call the
    function with appropriate input values to execute the function.
    I can't really figure out, what I did wrong and I would be very thankful, if somebody could help me.
    Regards,
    fuchrist
    Solved!
    Go to Solution.

    Hi,
    MathScript does not support inline user-defined function (UDF). What you need to do is
    Define the UDF in a .m file. Give that .m file the same name as your UDF.
    Save the .m file in MathScript Search Path. By default, the search path is the LabVIEW Data folder.
    Pass the name of .m file as the first string input to function fsolve in MathScript Node.
    I attach my .m file and snapshot of MathScript Node. The result I got is [50, 60, 70] which should be correct.
    Attachments:
    myfun.zip ‏1 KB

  • Solve equation with one unknown parameter (x)

    I am working on a Windows Phone program that calculates taxes due. One of the calculations is a formula/equation with an unknown 'x'. I have searched a lot on solving equations with vb but this really exceeds my - admittedly small - math knob. Perhaps you
    can help me out.
    The equation to solve is (for example):
    ((25000 + x) * 0.06) + x = 16500
    The only unknown variable is x. Does someone know the proper code to solve this equation?

    Are you looking to code some super-intelligent maths equation solver that can solve any type of equation (if so - good luck!)? Or are the equations you want to solve all of the same type?
    The example you gave is of the form (A + x) * B + x = C. You can rearrange that to (1 + B) * x + A * B = C and from there to x = (C - A * B) / (1 + B).
    If all your equations are in that form, you just need to identify the value of A, B and C and use the last formula I gave to calculate x.
    I wasn't going to do that for him.
    Let's see here, he's building a program for tax calculation and he can't do 8th grade algebra??
    Still lost in code, just at a little higher level.

  • Help with solving Riccati Equation

    Hoping someone can help me out with solving this equation.  The continous algebraic riccati equation is set up in the form A'*X + X*A - X*B*X + Q.     There is a riccati solver in the control and simuation toolkit but the equation is set up as A'*X + X*A - [X*B + N]*inv(R)*[X*B + N]' + Q = 0.  Default for R is just the identtity matrix, and default for N is empty matrix so does this reduce to A'*X + X*A - X*B*B'*X + Q  ?  (Not 100% on that.)   So is there anyway to use labviews CD Continuous Algebraic Riccati Equations VI on my equation?
    Thanks so much for any help.

    I think you are correct.  I think that technically the last X is transposed, but since X is symetric X' = X, so it makes no difference.

  • Can I solve 3 nonlinear equations in LabWindows/CVI

    I have 3 nonliear equations with 3 unknowns (x^2, y^2, and z^2) and get the roots?

    There is no CVI function for finding nonlinear roots, but you can use any other C routine, e.g. the ones provided in the GNU Scientific Library 

  • Is there a limit on the size of the input for the Solve Linear Equations block?

    Hello,
    I'm trying to figure out why the Solve Linear Equations block will properly function with some sets of data and why it won't with others. What my program is doing is taking a signal and comparing it with a batch of sine and cosine waves to try and pick out patterns in the data. I have different sample sizes and it seems to work when I throw 3900 points at it. However, I have another set with 4550 points and it gives me incorrect amplitudes for my sinusoids.  Is there some limit to the size of the matrices that I can give this block? Or is there some other workaround that still allows me to keep all of my data?
    Thanks,
    David Joseph

    Well, the best way to show what I expect is to see the entire program. It's pretty evident that when looking at the graphs, something isn't right. What is supposed to happen is that the runout amplitudes are found, and then those sinusoids are subtracted from the initial data, leaving tooth to tooth data and noise. When I use the larger arrays, it seems as though not all of the data gets through (count the peaks on the product gear runout graph vs. initial) and the amplitudes are much to small, such that nothing is really taken out and the tooth to tooth data looks like the initial data.
    Also, we will also be using an FFT, but it will be limited to only determining the frequencies we should check. I've fought with the fft blocks quite a bit and I just prefer to not use them. Plus, the guy I'm writing this for wants exact answers and does not want to pad or resample the data or use windows.
    The exact number of data points isn't important (ie. 4550 vs 4551) since I use the array size block to index the for loop.
    As for typical values, they can change a lot based on materials. But, the original 3900 data point sets and the 4550 data point sets used practically identical gears. So, use the original 3900 sets I've included as references (check the RO array block numbers to compare).
    I've included 3 3900 samples, 3 4550 samples, and 3 4550 samples that have been truncated to 3900 or so as constants on the block diagram.
    Also, the check for additional runouts (like 3 per rev, 4 per rev, etc..) is optional, but if you choose to use it, use positive integers only.
    I don't know how much of this program will make sense and I have wires running everywhere.. so good luck. Keep in mind I'm only a student and I hadn't touched Labview until about 2 or 3 months ago.
    Thanks,
    David Joseph
    Attachments:
    Full example.vi ‏139 KB

  • Equation with dynamic variable

    Is it possible to use one equation with 2 or more variables and make one of these variable as an output without changing the equation?
    Take the equation below example:
    R=x/(0.28706/0.46153+x)*(101.325/P)
    As usual, by inserting the values of x and P, then value of R will be answered.
    But if only the value of R and x can be inserted, how can the value of P to be answered without altering the equation.
    The equation is being used multiple time in the same VI. One is for generating one part of a graph (Mollier Diagram) and the others are to be used to find the value at the intersection.
    I hope my question is understandable.
    Thank you in advance
    -sikat
    Solved!
    Go to Solution.

    R = (x/(a+x)*(b/P) ... thx, this really will be helping me to make this Eq more understandable
    Formula Node:
    It seem that when i entered an equation(Eq), only the left side of the Eq can only be one variable thus producing a single output.
    Case Structure(or SELECT function):
    It changes the formula to a new form for every output. Let say i want make x an output. That means i need to create a new Eq : x=(P*R/b-1)*a, which i want to avoid if posible .
    .... Does this means that a new Eq must be created/converted for each output.
    Newton Raphson zero finder vi: (base on this N-R Example)
    I have tried using this VI by making my Eq equivalent to zero and using SELECT function depending on situation. Somehow i think it will work, but the VI seem too bulky for one simple formula (with 2 variable and 1 output), which i want to avoid since many more formula will be used.
    I ll be glad to see more suggestions.

  • Solving Differential Equation - getting strange results.

    Hi, i am using LabView to model the mathematic pendulum which comes down to solving the quation numericaly:
    where w is constant and 0 is an angle between the pendulum's cord and the vertical which i want to plot against time. I built this very simple model to solve this equation (this is what our teacher showed us) [x is the angle]
    and this is what i get:
    "fi" is the starting angle. The result is a cosine , as it is to be expected, with the right period, but why the amplitude is so low? Am i missing something here? No matter how i change the initial value, the amplitude is always 5 oders of magnitude lower. It wouldnt be a problem, since what we are required is to solve the equation, but when i want to factor that in the equation above 0 should be sin0 , the problem arises - sinx for so low x , is...x. So my questions are:
    - am i setting the initial conditions wrong?
    - has the value of dt anything to do with it?
    - is the method correct?
    - am i clueless? 
    A week ago i had no idea what LabView is. We were all thrown into the deep water, we were shown the method, but were not teached how the LabView works,so please, be kind.
    Thank You in advance .
    Attachments:
    pendulum.vi ‏14 KB

    Hello;
    Noise is a difficult issue to advise about.
    There are some things you can try, but the result will depend on different factors, such as, environment, lenght of cables, equipment on vicinity, etc.
    Anyways, you can try to hook up a BIAS resistor in between the ch- and AIGND on your BNC device. That resistor will bleed out the common voltage current and help on noise balancing. Another thing you can try is to hook up a simple RC low pass filter at the analog input. That might help to get rid of that noise.
    I'm also attaching an App Note that talks about Noise and some ways to get around it.
    Hope this helps.
    Filipe A.
    Applications Engineer
    National Instruments
    Attachments:
    Field_Wiring_and_Noise_Considerations.zip ‏196 KB

  • Solve Linear Equations NaN return

    I've implemented a modified Linear Levenberg Marquardt function for gauss fitting of spectral data, but have problems from time to time where I simply can't fit a specific data set.
    I've traced the problem to the function "Solve Linear Equations" outputting NaN for one or more solution vectors (Not all) which then plays havok with my function.
    I've located a data set which is initially OK, but which after solving the linear equations has NaN as the second element of the solution vector array. Changing the matrix type to something other than "generic" gets rid of the NaN for this particular data set, but gives problems with others which work with the "generic" matrix type.
    Since my mathematics lectures in college are a few years away now, I'm asking someone out there if they can help me with my problem. I can supply a "corrupting" data set if this would help, or maybe someone knows this problem and has a work-around?
    I've thought of leaving the matrix type to "generic" and checking the output to see if there's a NaN present, and if so, then re-calculate with another matrix type until there's no NaN. This is most likely not very sound mathematically, but it might reduce the number of rogue data sets.
    Thanks in advance
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

    Hi Altenbach,
    The data can have a significant amount of overlap. Typically three to four groups of peaks fully resolved, but each group can have up to 4-5 peaks in them, partially visible only as shoulders.
    The start value "problem" is more or less solved (but as usual, not yet finished).
    I've got an approximate first-guess peak find running which does a pretty good job of finding the peaks I need, and I then fit the height and FWHM first before doing a full optimisation (The Sub-VI approach allows much more flexible fitting models).
    The fitting works well on almost all data sets. There are simply some spectra which (although visibly hardly different to others which work perfectly) do not fit, i.e. generate the NaN response from the "solve linear equations" function. It's a numeric problem (bug?), I'm sure, and not strictly a peak location or resolution problem. then again, I may be wrong.
    I refer to the standard "LevMar" VI as being linear, because it assumes a linear relationship between the variable variation and the end mse used for optimisation. This is where the "Solve linear Equations" comes in. Since the relationship is almost certainly not linear (foe example when peaks overlap), I thought maybe the non-linear coefficient guess may yield better results. I've had a quick look through the non-linear LEV-MAR function, but don't understand it yet ot the extent I understand the linear one. It does indeed seem to take a slightly different approach (once you look past the whole parsing code of the "linear" function.
    I'll need some time to get some understanding of the non-linear code.
    Attached are some example spectra (One which works, and one which doesn't).
    Thanks again
    Shane
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Spectra.zip ‏3 KB

  • How to solve this equation?

    can anybody help me, solve this problem in as3 ?
    x+y+z=8000;
    0.17*x + 0.35*y +0.08*z =960
    thanks very much!!!

    this gives a little more explanation, although doesn't actually complete for me there are too many permitations
    you are also going to have to worry about the number representation issue using floating points numbers
    it might be better to convert the second equations to something equivalent which uses ints
    package
              import flash.display.Sprite;
              public class Main extends Sprite
                        //x+y+z=8000;
                        //0.17 * x + 0.35 * y +0.08 * z = 960
                        public function Main()
                                  // consider each equation in the form a.x + b.y + c.z = d
                                  // we have 3 unknowns x, y, z so we need 3 nested for loops to run over all possibilities
                                  // then the maximum value x can be is d/a
                                  // maximum y = d/b
                                  // maximum z = d/c
                                  // now if we have 2 equations we need to take the maximum for each known from either equation
                                  // so in your case with maximum x is the maximum of 8000/1 and 960/0.17 =
                                  // maximum y is the maximum of 8000/1 and 960/0.35
                                  // maximum z is the maximum of 8000/1 and 960/0.08
                                  // all these maximums should be rounded down to the nearest integer
                                  //max x = 8000
                                  //max y = 8000
                                  //max z = 12000
                                  //we use these maximum values for the nested for loop limits
                                  var maxX:int = Math.max(8000 / 1, 960 / 0.17);
                                  var maxY:int = Math.max(8000 / 1, 960 / 0.35);
                                  var maxZ:int = Math.max(8000 / 1, 960 / 0.08);
                                  trace("max values: ", maxX, maxY, maxZ);
                                  for (var i:int = 0; i < maxX; i++)
                                            for (var j:int = 0; j < maxY; j++)
                                                      for (var k:int = 0; k < maxZ; k++)
                                                                // this if statement is a representation of if the values for x, y and z we are trying
                                                                // actually solve the equations
                                                                // so in your case use the following
                                                                if ((i + j + k == 8000) && (0.17*i + 0.35*j + 0.08*k) == 960)
                                                                          trace("x=", i, ", y=", j, ", z=", k);
                                  trace("done");

  • Solve linear equations vs pseudoinverse memory issues

    Hello,
    I am trying to solve a Ax
    = b system, and have setup my algorithm to use the LU decomposition
    followed by the appropriate use of the "Solve Linear Equations" VI. I
    then check the error output from this VI, and if there is an error I
    try using the "PseudoInverse Matrix" VI.
    I am doing this in a loop with a progressively larger matrix for each iteration.
    This
    works great EXCEPT for when my algorithm gets close to the maximum
    memory allowed (i.e. - the iteration BEFORE I get an error message
    stating that the VI has run out of memory).Then, although I do NOT get
    an error code from my "PseudoInverse Matrix" VI, the values output from
    this VI are complete garbage (really really large values).
    Has
    anyone come across a similar issue before? Is there a way around this?
    i.e. - I would like to know when/if the  "PseudoInverse Matrix" VI will
    not provide valuable data output so I can stop my algorithm the
    iteration beforehand.
    Thanks!

    Zamjir,
            Can you post the VI and the matrix needed to replicate the issue? I didn't find any other instances of this happening but that doesn't mean that it's not expected. I understand that things ramp up in memory and just before it tops out it shows large (not correct) values but I don't know if this is expected and is just LabVIEW's way of letting us know that it's about to error out (in case you wanted to build in a shut down program you could base it off of these large values) or if it is a bug. If you could post the code so I can take a look at it and also a screenshot of the "out of memory" error you see, I will see what I can find out for you. 
    Grant H.
    National Instruments
    LabVIEW Product Marketing Manager

  • How to build an equation with variables

    I want to solve an equation shown in below by the Newton Raphson zero finder vi:
    z-a*b*c*exp(-z/a),
    a, b, and c are variables
    I can build equation with constant a,b,c, but how can I build this one?
    Many thanks!
    Solved!
    Go to Solution.

    A couple of points I usually feel compelled to make when I see the use of the NR method.
    1)  Not an issue in a simple case like this, but the NR routine is typically a poor choice when you have a 1D problem and you calculate the derivative numerically.
    2)  If I am going to hardwire the formula like the previous example, then I will just use a VI instead of a formula.  I only use formulas when I want to be able to make changes on-the-fly.  I am just a bit dubious of the formula parsing VIs in general.
    3) There is a VI called Substitute Variables which will take a set of rules and substitute numbers for parameters in your formula.  Here is a quick example of its use.  Here the names and number of parameters is fixed by the cluster itself.  If I need full flexibility I use a table to hold the parameters and their values, but I do not want to muddy the waters here.  You can just choose your favorite UI and convert (if necessary) to the proper cluster for the substitution rules.

Maybe you are looking for

  • Document not display in FB03 ?

    HI All Experts, One document posted on 09.07.2009 is not able to display in FB03. However I am not able to know that whether that document is archived or deleted ? So any one can tell me how would I know that what happened to document ? How to see th

  • HT3176 How do you use the submit command?

    HOw do I use the Apple TV remote to submit after typing?

  • Function in Query causes code to run slow

    Hi, I have code which has a function in the WHERE statement, ie SELECT col1, col, col2 FROM tab1, tab2, tab3, tab4, tab5 WHERE tab1.end_date between :date_from and :date_to tab1.col1=tab2.col1 and tab1.end_date between tab2.start_date and tab2.end_da

  • Unable to check the "calendars" checkbox in isync

    I want to Sync my calendars with my razr phone, but when i try to check the calendars checkbox, a dialog box pops up telling me i need to start ical, I click the open ical button, ical opens, but the checkbox still does not check. I click the box aga

  • OLAP Component is invalid

    Hi, We have a environment where current version of database is 10.2.0.4 but OLAP component version shows 9.2.0.7 from dba_registry and it is invalid. What could be the possible solution in this case. removeand re-install the OLAP components will help