LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering 2d array by data in 1 column

Solved!
Go to solution

Hello, allow me to thank you ahead of time for your help with this.

 

I am trying to figure out a method of taking a 2d array, and pulling out a specific section of that array based on numbers in one column.  If it were excel, then I would, for example, be pulling rows 28-65.  Specificaly, I want to pull all of the amplitudes associated with a range of frequencies.  You can set theupper limit to be one frequency, and the lower limit to be a second frequency, and a subarray will be created based on an original array which contains the results for that specific range.  For everything I have tried, the end result is an empty array.  I will paste a link of my labview code below.

 

This program is to find the lev-mar best fit equation for the vibration amplitude based on freqency.  It reads in data which has already been obtained.  The only parts that I am working on is the best-fit vi, and it has to be run for each natural frequency position, which is why I am trying to build he array filter.  If you see a better way to perform this function, feel free to point that out as well.  Some of the code, for example the two arrays which show the result after the filter, are for me to be able to see the result while I am trying to make the filtering work.

 

Thank you again for your help.

0 Kudos
Message 1 of 9
(4,308 Views)
Solution
Accepted by topic author CStephens

This shows you how to get a subset of all rows, where the number in the first column is between 400 and 500 (inclusive). The bottom for loop is how I'd do it before LV2012. If you have LV2012, I'd use the top loop.

 

The array functions I used, from left to right, are index array, replace array subset, and array subset.

 

Message 2 of 9
(4,282 Views)

This worked, thank you very much.  However, do you see anything wrong with the way I have programmed in the best-fit vi?  I am still getting the -20041 error, and I can't figure out why.

0 Kudos
Message 3 of 9
(4,262 Views)

@CStephens wrote:

This worked, thank you very much.  However, do you see anything wrong with the way I have programmed in the best-fit vi?  I am still getting the -20041 error, and I can't figure out why.


Can you:

 

  1. supply a data file?
  2. Put reasonable guesses (initial paramters) in the respective control, make them the default, resave, and reattach the VI?
  3. Same for the max and min frequency controls and any other controls where you don't use the default.
0 Kudos
Message 4 of 9
(4,247 Views)

Sure thing, data file is attached.

 

For best guesses, amplitude, a0 = 462.1, natural frequency, a1 = 328, and zeta, a2 = 0.05.  Also, max and min frequency should be set to 340 and 300, respectively.

0 Kudos
Message 5 of 9
(4,241 Views)

Your formula is screwed up and only returns zeroes.

 

For troubleshooting, you should ALWAYS compute the function based on the guess parameters to see if the function looks reasonable. Currently, it does not.

 

(I typically use the VI model. What is the formula? Do you have a link to a website describing the theory?).

 

 

Here's a quick testbench.

0 Kudos
Message 6 of 9
(4,233 Views)

Basically, this is the equation that I am trying to input.

 

|FRF|=A/sqrt((w_n^2-w^2)^2+( 2*zeta_n*w_n*w)^2)

 

Where FRF = frequency response function and is the dependant variable, A is the amplitude at the natural frequency (constant), w_n is the natural frequency (constant), w is the frequency (independant variable), and zeta is the damping force (constant).

 

I used this model for the simple fact that I'm not sure how to use the VI model, and this method seemed to make more sense to me.

0 Kudos
Message 7 of 9
(4,224 Views)

Do you have a link describing the theory?

 

The fit will not work until you can generate a function using the best guess parameters that roughly has the features you expect. (a peak at a given position, etc.).

(I don't think you need the second "abs", because you are summing squared values)

 

In my earlier attachment I show how to use the model to calculate the result of your formula definition. Play around with it!

0 Kudos
Message 8 of 9
(4,220 Views)
0 Kudos
Message 9 of 9
(4,191 Views)