ChrisAnderson Posted July 31, 2009 Report Share Posted July 31, 2009 Cross-post disclosure: http://forums.ni.com/ni/board/message?board.id=170&thread.id=428823 I am trying to fit some rectangular complex data (S11 data for those with network analyzers) to a model using the Constrained Nonlinear Curve Fit vi in LabVIEW using the trust-region algorithm. I'm already doing this in Matlab after I've gathered and saved all my data, but would like to bring it into LabVIEW. (Doing the fitting in Matlab has helped me become more proficient in it, distributing and installing two run-times and the executables has become an unnecessary pain.) However, the VI only accepts double, causing me to lose all of the phase information I need to do the extraction. Is there any way to send CDB data or will I have to attempt to rewrite the VI and its sub-VIs, replacing DBL with CDB? Thanks, Chris Quote Link to comment
HeLo Posted August 2, 2009 Report Share Posted August 2, 2009 Hi Cris, I am guessing that in your matlab code you minimize the square of the distance of experimental and theoretical values. This means, you are minimizing the sum: "sum of (Re_theortical - Re_experimental)^2 + (Im_theoretical - Im_experimental)^2). This means that you should be able to easily implement this with reals only: Arrange your experimental data for example such that y0=Re(z0) and y1=Im(z0), y2=Re(z1), y3=Im(z1), .... and the acquisition times are t0, t0, t1, t1, ......... Now, what you have to do is write your fitting function such that it computes the real part of the theoretical function for even indeces and the imaginary part when the index is uneven. In terms of speed, I would use a case structure and toggle between false and true. Then, if it is possible to calculate the derivatives analytically, I would code them in the same manner. Maybe, this description is a little short but please ask again, if I am not clear enough. Herbert Quote Link to comment
ChrisAnderson Posted August 3, 2009 Author Report Share Posted August 3, 2009 Herbert, Thanks for the reply. I'll look into it today and post back with results. Chris Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.