LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

interpolating a 2D array

Solved!
Go to solution

Hey guys I am currently working on some code that should interpolate a 2D array.

I care about two columns for the interpolation one is the "Tesla" column and one is the "EMU" column. The way the data works is that the Tesla values will go on a loop from -2 to 14 then back to -2. So in essence this could be broken up into a Field up and Field down. What I need to do is get the amplitude of the graph, I need to do this by using the points on the field up and interpolating these values with the field down EMU values so the Field/Tesla points could match up on the way up and down and I could use the corresponding EMU values.

Attached are the dummy file and the labview code.

 

All help is appreciated, thank you guys

Download All
0 Kudos
Message 1 of 11
(3,848 Views)

Convert your 2D array to an array of points, then use interpolate array.

 

See here: http://forums.ni.com/t5/LabVIEW/measure-percentage/m-p/2953749#M852011

 

 (Sorry, posting by phone, cannot see your code)

0 Kudos
Message 2 of 11
(3,824 Views)

I believe I am doing that in my code, I could be wrong though

0 Kudos
Message 3 of 11
(3,814 Views)

interpolate?

 

It sounds more like you want to merge two sets of data and sort them in order.

 

At least that is what it sounds like to me.

 

 

0 Kudos
Message 4 of 11
(3,801 Views)

OK, looking at the code now, it seem there are major problems.

 

  • Why are you writing FALSE to a value property node of the boolean button with every iteration of the loop? This makes the code highly unreliable, because we don't know what happens last (writing to the value property, reading the terminal, pressing the button). Depending on the order of events, the loop cannot be stopped with the button unless timed just right.
  • Why is the loop reading the same file over and over, 100 times per second? Does the file actually change constantly? Typically reading once is sufficient.
  • What's up with the array-to-cluster-unbundle dance? Just use index array!
  • What's the point of the big sequence structure? It is not needed.
  • What is the point of the small sequence and why does the FOR loop have such a long delay? Get it over with already!
  • Why are you building the 2D array into a 3D array array the end?
  • ...

Sorry, I simply don't "get" it. What is the final output you expect?

0 Kudos
Message 5 of 11
(3,788 Views)
  • I am writing false so that the button that breaks the loop gets initialized as a false
  • the for loop was just me trying to test out the code and how it would read the data, it could be removed. The data does not change once its written
  • the array to cluster dance was my inexperience of labview, looking back at it i should of used the index array
  • the big sequence structure is just for testing puposes when i highlight execution, it isnt needed you are right
  • same thing goes for the for loop, i dont need it with such a long delay, it was mostly for testing purposes
  • switching from 2D to 3D i thought was necessary, again my limited labview experience

so my expected output is matching points for field on the way up and down, I need matching field values in order to get the corresponding EMU value for further data analysis. the reason I have to do this is because my field values on the way up and down do not match up although they are very close to each other.

 

I appreciate all the help, I havent had much work with file I/O and arrays using labview

0 Kudos
Message 6 of 11
(3,755 Views)

@julianv23 wrote:
  • I am writing false so that the button that breaks the loop gets initialized as a false

If you want to initialize the button, this needs to happen before the loop. The correct solution would be to change the mechanical action to latch when released (right-click..mechanical action). This way it is true when you press it but reverts to FALSE automatically once the value has been read by the code. No property node needed.

 


@julianv23 wrote:
  • so my expected output is matching points for field on the way up and down, I need matching field values in order to get the corresponding EMU value for further data analysis. the reason I have to do this is because my field values on the way up and down do not match up although they are very close to each other.

Sorry, I just don't get your description, too diffuse. What is "matching" in this context? What is the expected output? Do you want to fold the ramp-down values into the ramp-up parts?

0 Kudos
Message 7 of 11
(3,748 Views)

Just for reference, here's how you would read the file to get the same output as you currently do.

 

You still need to explain what you want for the missing output.

0 Kudos
Message 8 of 11
(3,743 Views)

So lets say my array looks like this

Field = [ 1, 2, 3, 4, 5, 4.6, 3.6, 2.6, 1.6]

EMU = [ 1.1, 1.3, 1.5, 1.7, 1.9, 1.8, 1.6, 1.4, 1.2]

 

I would like to get the corresponding EMU values for a certain field. For example, if I input the array above, I would want my interpolation to give me an array looking like this

Field = [ 1, 2, 3, 4, 5, 4, 3, 2, 1]

EMU = [ 1.1, 1.3, 1.5, 1.7, 1.9, Yi, Yi, Yi, Yi]

 

 

In other words, I want to use the field value on the way up and interpolate these values with the data for the field down in order to get matching EMU values at certain fields. This will allowme to make a delta EMU calculation.

0 Kudos
Message 9 of 11
(3,741 Views)
Solution
Accepted by topic author julianv23

See if this gives you some ideas....

 

 

Message 10 of 11
(3,732 Views)