LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Non-linear curve fitting for complex data

Darin K

 

Did you see my last post?. I just wanted to make sure you didn't miss it. 

0 Kudos
Message 21 of 44
(1,758 Views)

Mbdeck wrote:

Darin K

 

Did you see my last post?. I just wanted to make sure you didn't miss it. 


 

 

 

Same question, back at you.

0 Kudos
Message 22 of 44
(1,756 Views)
Ok I missed it. Thanks.
0 Kudos
Message 23 of 44
(1,750 Views)

Hi Darin K,

 

I tried to use the VIs you helped me build but it is not working. I don't think I provided enough information so I will outline what I'm trying to do so you can make recommendations and corrections. Below is the outline, If you follow it, you will get a better sense of the outcome I need and make the right changes.

 

1) I'm trying to create a Nyquist plot of the Fit and the Raw data. The frequency data is suppressed in a Nyquist plot. It is basically a cartesean complex plot of the Imaginary data on the y-axis Vs the Real data on the x-axis. Please see attached excel plot of the raw data to get a sense of what the plot should look like.

 

2) The frequency x is used in the complexfunction VI to evaluate the model function f(x,a) but suppressed in the actual curve and it's fit.

 

3) I want to be able to copy my raw data and paste it on the front panel string control and run the VI afterwards.

 

4) Just to reiterate, I only need a plot of Imaginary impedance data Vs Real impedance with f(x,a) evaluated at all values of x in the complexfunction VI but x is suppressed in the actual plot of the data and the fit.

 

I decided to build my own VIs from scratch to perform the task I needed it for but It has errors in it and I've attached it. Please take a look at it after reading the above and see if what I just outlined makes sense to you. I will really appreciate it if you can help me get this working.

 

Thanks again.

0 Kudos
Message 24 of 44
(1,730 Views)

What do you mean not working?  Errors, bad fit, not plotting the way you want...  I run it, it gives me a result, sometimes the values are not realistic so I give it better initial guesses and it seems to work.  Also, your Excel data plot is clearly not a text file.

 

For a Nyquist Plot, just put a 1D complex array into an XY graph and you get Real vs Imaginary turn on the Nyquist plane if you'd like.  Right-click and find the optional plane menu (I think it is there in LV8.2).

 

Use the code I showed earlier to convert to data from a string control, only stop using commas in the frequency values if possible.  Otherwise, use Search and Replace to get rid of them.

0 Kudos
Message 25 of 44
(1,720 Views)

Hi,

 

I had wanted you to look at my new code and see what I did wrong and perhaps modify it but I will try to work the your ComplexFitExample VI.   

 

1) I couldn't figure out how you incorporated the conversion of the data from the string control in your block diagram. I can't find it on the block diagram. I was confused by that. In the new vi I created, I tried to use your conversion code as a subvi.

 

2) I right clicked the xy graph and selected Nyquist and the plot but it still does not change when I run it with different initial guess values. All I need is to have a plot of the data and the fit in a Nyquist form.

 

Can you show where the string conversion code appears in the blockdiagram of your fit VI?

 

3) I can see you have two separate array entries for the complex data and x data on the front panel and block diagram but I can't find the reference to the conversion. 

  

4) Can you look at my new curve fit vi and see whether it can even be modified into a working VI, assuming it isn't too much hassel for you. Honestly I wish I can speak with you on the phone because it will be easier to resolve that way.

 

Anyways thanks for your help though.

 

 

 

 

0 Kudos
Message 26 of 44
(1,713 Views)
 No LV on this machine, I'll look at the code later.

 

1) I couldn't figure out how you incorporated the conversion of the data from the string control in your block diagram. I can't find it on the block diagram. I was confused by that. In the new vi I created, I tried to use your conversion code as a subvi.

 

I showed it in a snippet a few posts back.  Get rid of the commas, use string to spreadsheet array followed by index array.

 

2) I right clicked the xy graph and selected Nyquist and the plot but it still does not change when I run it with different initial guess values. All I need is to have a plot of the data and the fit in a Nyquist form.

 

You need to feed the complex data array into the XY graph.  Take the array that comes out of the LM fit VI just after the typecast to CDBL and feed it straight into an XY graph.  If you want to have both data and fit on the same plot use "Build Cluster Array".  Resize to two inputs, wire one input to the complex data, one to the complex best fit array and you have it.

 

Can you show where the string conversion code appears in the blockdiagram of your fit VI?

 

3) I can see you have two separate array entries for the complex data and x data on the front panel and block diagram but I can't find the reference to the conversion. 

 

The data passes through a Type Cast function to DBL array.  This converts the complex data array to a array of real values which are alernating real/imaginary components Re[0],Im[0],Re[1],Im[1],....

  

4) Can you look at my new curve fit vi and see whether it can even be modified into a working VI, assuming it isn't too much hassel for you. Honestly I wish I can speak with you on the phone because it will be easier to resolve that way.

 

I'll look at it when I get a chance, I suggest you keep plugging away.  As to the phone, I am afraid that's not how it works around here.  

 

 

 

Anyways thanks for your help though.

 

 

 

 


 

0 Kudos
Message 27 of 44
(1,705 Views)

Darin K,

 

I know you showed a snippet of the data conversion code earlier but what I'm saying is that I don't see where you called it on the blockdiagram of your ComplexFitExample VI. You should look at it again to understand what I'm trying to tell you.  Perhaps there is a method that you used where that section of code isn't dispalyed on the blockdiagram.

 

For someone who just learned recently to write simple codes in labview it is confusing.

 

Also, only the array controls of the data and frequency are displayed on the front panel while the string control where you paste the raw data isn't. Why is that?. How did yo do that? Did you do "hide control and code" or something?...I don't know...

 

I've attached your VI again so you can see.

 

 

0 Kudos
Message 28 of 44
(1,689 Views)

I ran that code as a separate VI and copied the data itself into the arrays, you can add it to the block diagram, column 0 is x, column 1 and column 2 are the data.  If I were you I would write a subVI that gives converts the string to the necessary arrays (using the code I showed you).  Write a second subVI for the Fit (again the code I have given you).  Wrap it all up in a Single VI that has your string input and graphs for output.  Using subVIs will give your code more flexibility in the future.

 

Another piece of advice is to study the available LV tutorials, it will pay great dividends later.  It will help you to understand my code, and you are better off learning the basics from them than from me.

0 Kudos
Message 29 of 44
(1,687 Views)

Hi Darin K,

 

I already have learned labview basics, it's just that the way you put down your code without mentioning a few minor details made it a bit confusing.

 

Anyways, I have finished my new code and there are no errors in it. The issue now is that it doesn't work properly. For example, I put in my initial parameters and run the vi, it returns the same numbers and doesn't plot the graphs. It just plots a straight line on the xy graph.  I copied and pasted the raw data into the VI and used a subvi to convert the data. Everything seems to be in order I just don't know why it is not functioning as it should.

 

 I've attched the completed VIs so please check it see if you could find what the problem is.

 

Thanks

 

 

Message Edited by Mbdeck on 11-09-2009 07:23 AM
Download All
0 Kudos
Message 30 of 44
(1,671 Views)