LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing values on certain indices back to "null" possible ?

Hi, guys

 

I hope somebody can give a little hint. I've two arrays with the following data

 

Encoder Array

 

Index 0,1,2,3,4,5,6,7,8,9,10

Value 0,10,20,27,38,43,50,55,65,73,90,100

 

Signal Array

 

Index 0,1,2,3,4,5,6,7,8,9,10

Value 0,1.0,2.0,2.7,3.8,4.3,5.0,4.5,3.5,2.8,1.0,0

 

So basically I "just" want to align the SignalArray values with the EncoderArray values and then interpolate the data points (not only for display reasons so I would need the adjusted data in an array).

 

My first idea was to rebuild the Signal Array using the values out of the encoder array as an index. If I create an empty 100 value array, I can write the samples from the signal array into the right indices (corresponding to whatever the encoder value was) but now I've Zero-values in between and can't get the interpolation functions to work properly.

 

I'm sure that's a very simple task for an experienced LV user but since I'm a newbie I've a hard time with it. Any help is highly appreciated. Thanks.

 

 

 

 

0 Kudos
Message 1 of 9
(987 Views)
I don't quite understand what you mean by "aligning" the SignalArray with the EncoderArray. Both arrays are the same length - 12 elements. I'm ignoring the "Index" row because I don't know what the purpose of that is. Why would you be looking for a 100 element array? Are you trying to pad the array(s)?
0 Kudos
Message 2 of 9
(959 Views)
Sorry, with "aligning" I mean to correct the unequal spacing between each reading. Before interpolating the signal array I would need to "correct" the spacing first so that the signal array represents what happened in reality. I believe the "experienced" user would have seen this problem up front and not even bothered working with 1D-arrays. 2D-arrays are probably the solution. I was just wondering if I can "erase" zero values out of an array as if they would have never written into it. I need to admit, that this whole array handling is still very confusing to me, especially because I spend a lot of time just searching for the right functions (symbols) ;-).
0 Kudos
Message 3 of 9
(936 Views)

You're still not being precise or even clear in your descriptions. What does "equal spacing" mean to you? It means one thing to me. It means something else to somebody else. For the array 0,10,20,27,38,43,50,55,65,73,90,100 what's "equal spacing" supposed to be? Every value that's a multiple of 10? Every value that's a multiple of 5? Every value that's a multiple of 6.235? What about the array 0,1.0,2.0,2.7,3.8,4.3,5.0,4.5,3.5,2.8,1.0,0? That's even less clear by what you mean by "equal spacing".

 

As for eliminating zeros out of the array, how is the array accumulated in the first place? If you're doing it one element at a time then you can use a trivial solution of conditionally adding to the array using a case structure that's driven by a check to see if the value is nearly zero. NOTE that I said nearly zero. Don't try to use a Equal operator on zero and come back and complain that LabVIEW has a bug that it can't compare a float to be equal to zero. If you're trying to do this after the fact there are several ways to do this. If you search the forum you will see this question has come up many times, and several solutions have been posted. 

0 Kudos
Message 4 of 9
(928 Views)

I'm also unclear what you are trying to do to "align" the data. Isn't the signal data at index 3 representing the data taken when the encoder was at index 3? If you were to graph it out with signal data on one axis and encoder data on the other, wouldn't that be representative of the aquired data? If so then there are LabVIEW functions to do various curve fits, with one array supplying the X-axis data, the other the Y, to interpolate between, I presume, the encoder inputs.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 9
(921 Views)

Hello,

 

It sounds like you simply want to define the sampling interval between the data points in your array. If these are evenly sampled, the attached example should help. By graphing the points as a waveform, you include the sampling interval:

Spacing.png

Spacing Result.png

-Zach

0 Kudos
Message 6 of 9
(912 Views)

<If you were to graph it out with signal data on one axis and encoder data on the other, wouldn't that be representative of the acquired data?>

 

Exactly this is what I'm trying to do. I guess, the graph would use some internal "interpolation" to connect the points which I provided. But as I mentioned in the initial post, I do not only need the graph but the final "interpolated" data in an array which I can later search for specific values (even those values which I didn't provide in the first place). For example, I've a sensor reading at encoder position 50 and another one at position 65. But I need to know what the reading would have been at let's say encoder position 54. I know, that will be just a calculated value but likely very close to what has been the "real" value.

 

 

0 Kudos
Message 7 of 9
(910 Views)

So why dont you fit your data to a curve?
Once you have a formula that describes the curve, you can generate an array with however many points you want, with any dt you want.

Cory K
0 Kudos
Message 8 of 9
(906 Views)
<"LabVIEW functions to do various curve fits">, which will give you the theoretical points between the encoder readings, if the input function is "well behaved"
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 9 of 9
(899 Views)