LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search and Interpolate an Array

I have a VI which currently reads in an excel file and graphs the data.  The data is particle size on the x axis and particle crosssection on the y axis.  The goal is to insert a value for the cross-section (currenty defaulted to 397) and find the corresponding size by interpolating between data points. The issue is that there may be several instances where the data corresponds to a cross-section of 397.  Currently my code will find the first time this occurs and then stops.  I want to have it keep searching the data and add each time it crosses the desired valve to an array.  I have tried building while and for loops to try to perform this search, but so far I have been hitting a brick wall.  Any suggestions as to what I might try would be appreicated.  I have attached the VI and the data sheet for convenince.  Thanks

Download All
0 Kudos
Message 1 of 9
(3,173 Views)

You could do a moving average to attempt to smooth out your curve.  Another option is to do a regression to make a curve that you then use for your interpolation.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,157 Views)

Thanks for your relpy. Unfortunately, the person I am building this code for does not wish to smooth the curve.  They want to use the data as is which is why it is important for me to be able to find each time the a value occurs.  Also, I already have the interpolation working.  The issue is that I cannot figure out how to keep searching past the first value the code comes across.

0 Kudos
Message 3 of 9
(3,151 Views)

@Cseaman wrote:

The issue is that I cannot figure out how to keep searching past the first value the code comes across.


Use a While Loop with the Interpolate inside.  Have the loop stop when the returned index is 0.  The index should be stored in a shift register so you can tell the Threshold 1D Array where to start the search.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 9
(3,145 Views)

Sorry to be such a bother, but this is getting into parts of labview that are new to me.  I understand how to create a while loop and place the interpolation block inside.  It is the implementation of the shift register and return idex that is throwing me off.  So let me walk through the steps and see if I can figure this out.

 

1) Create a constant which starts at 0 outside the loop so it starts searching at the begining of the array.

2) Wire this to the threshold block starting index terminal and convert tunnel to shift register so when the loop stops it updates to where it stopped and will continue searching from that point.

 

This is where I get stuck. 

 

How do I find the return index and what do I connect the exiting shift register to?  I think know how to stop the loop if I can find it.

 

labview.png

 

0 Kudos
Message 5 of 9
(3,134 Views)

Actually, now that I have done a little playing around, just use the Threshold Detector VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9
(3,114 Views)

The threshold is a nice idea.  The problem is that it only sees the rising edge values and also does not provide the excat loaction of when the data crosses the desired y value like it does in the interpolation.  I have been working on creating a way to continue the search.  Currently it is set up to run two iteration (this will change so that it will run through all the data but I wanted to simplify things to start).  I have it set up so that is should start searching a subset of the array that comes after the first threshold value.  The problem is that it doesn't seem to perform the second interation correctly as it keeps returning the location for the crossing at an index of 0 and it should be between 2 and 3.  I have attached the VI. Thanks.

0 Kudos
Message 7 of 9
(3,081 Views)

Just an update. I was playing around with my code and foud that if I update the intial index (currently 0) to start after the index associated with the crossing I just get it spitting out that index.  Ex.  Currently the first value occurs between 985 adn 986.  If I tell it to start looking after 986 is just spits out that the interplated value is 986.  If I put in 987 I get an output of 987.  This is wrong because the next occurance happens between 988-989.  I am not sure why this isn't working correctly.  Thanks. 

Index issue.PNG

0 Kudos
Message 8 of 9
(3,066 Views)

I ended up switching how I found the points I needed and now have a VI which does what I want.  I am posting it in case anyone else would like to see how I solved my issue in the future.  It may not be the sleekest VI but it does get the job done.

0 Kudos
Message 9 of 9
(3,048 Views)