05-12-2025 02:52 PM
Hello people,
I need to process two arrays: one containing voltage values (X) where repeated values appear consecutively, like x5=2.05V=x6=x7=x8,and another with corresponding current measurements (Y), which slightly varies. For each group of repeated X values, I want to calculate the average of the associated Y values and generate two new arrays—one with the unique X values and another with the averaged Y values.
So for example for x=5.05V, I have 5 consecutive values in the X array and then I need to know the especific position of those 5 values in the array so I can allocate the values of the Y array and then calculate the average of those 5 values in Y and then save the average in a new array, lets say Y_average and also save the X value in another array X_new.
How can this type of search and save arrays be done in Labview?
Wen
Solved! Go to Solution.
05-12-2025 06:12 PM
The word "equal" for floating point numbers is tricky.
If the x values are quantized to a limited number of possibilities, this is quite a simple problem, especially since equal x values are adjacent.
What have you tried?.
Why not attach a simple VI containing some typical data?
05-13-2025 06:36 AM
I'm trying to do a curve tracer with Labview, so after measuring the I/V curve I get a curve with a lot of points around a specific curve like the following one.
So I'm trying to do an average of those points and represent the curve like they normally do in some professional curve tracers.
My professor recomends me doing an average point for intervals of for example 5mV, which I don't quite know how to that in LabView.
Another aproximation I can see is that, if I zoom a specific interval of the curve, there is multiple points which share the same X coordinate although not the same Y coordinate. Like the following figure:
So Im thinking about doing the average of those points with the same X and diferent Y because i guess its easier?
Some examples of the Voltaje_Example
Then I checked the typical data of the measurements, attached as txt, and I found that first, they are not ordered consecutively, and that makes the problem even harder to solve.
So any suggestions to solve this?
Ps: I tried switching different values of resistors, and with a higher value of resistor the variation of current(Well, I'm measuring voltaje in reality) varies a lot less.
Wen
05-13-2025 07:01 AM - edited 05-13-2025 07:02 AM
Hi Whens,
@Whens_Wens_Day wrote:
I'm trying to do a curve tracer with Labview, so after measuring the I/V curve I get a curve with a lot of points around a specific curve like the following one.
So any suggestions to solve this?
Why do you have ALL points in just one plot?
Why don't you create 10 (or 11) plots for the different traces in your image?
Separating those traces would make it a lot easier to filter the data…
What should we do with your measurement data?
How is the data organized/formatted (in your files)? Is there a meaning in the number of rows and columns?
05-13-2025 09:06 AM
Your data looks like one line from the voltage file corresponds to one line of the current file. So read both files with Read Delimited Spreadsheet and loop over both arrays. In the loop, build an array of clusters to sort the data.
For averaging and in your special case of multiple exact x-values, you can group by x-value and do an average.
If you have LV2019, you can use Maps with the x-value as key and a {sum, counter} cluster as value.
In earlier versions, or if you want a different grid, you could define an array of x-values and find for each input x the closest grid point. This is an example with a custom grid, you can swap it out against the sorted and deduplicated input x-values.
You should probably also filter out NaN values and ensure that every line has the same number of measurements.
05-13-2025 09:07 AM - edited 05-13-2025 09:09 AM
These curves seem to follow some simple mathematical model. If you have a formula, I would just do a nonlinear fit. This way you can reduce each curve to a handful of parameters.
Else, you could just some some filtering followed by decimation.
05-13-2025 09:59 AM - edited 05-13-2025 10:28 AM
Here's using a dumb polynomial, but I am sure you can find a reasonable model equation. Depending on what each trace means, you could even do a 2D fit to all data!
(Note that the data files need to be located next to the VI, but you can of course modify that)
05-13-2025 03:12 PM
Hi
I think the easiest way would be to average the original signal both x and y and plot them after the average, this would eliminate the noise you read when acquiring the data.
05-14-2025 12:04 PM - edited 05-14-2025 12:10 PM
Hi,
Cordm's solution looks amazing but I don't really understand your data flow.
What are the inputs for the sum_grid_values? And the cluster of arrays you introduce in Inicialize array is the sorted and deduplicated X values? And the other 2 inputs? Can I have a look of the vi?
Wen
05-14-2025 12:29 PM
Hi Gerdw,
Actually, I generate each especific trace of my image in a single loop and then I plot them consecutively in the same XY Graph.
They need to be plotted in the same graph to compare the behavior of the transistor across different regions of operation and to ultimately determine the operating point(Q-point).
I would want to do an average of the values for a certain grid, lets say 5mV, for each curve IV in which each value X is asociated with a Y value forming a pair. Lastly the data are just a array of lines separated with spaces.