LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modified Histogram LabVIEW Code

Solved!
Go to solution

Hello everyone,

 

I have a simple algorithm that I need to put into LabVIEW. I already have the pseudocode typed up, and it works when I coded it in Java, but for some reason, the translation into pictures is giving me a hard time. Basically, I want to do some array manipulation so that I can get a quasi-histogram. However, I don't want the histogram to tell me all of the occurrences within the array - just how many times it occurs in a row. I will provide an example below:

 

Input: Fuel = { 3900, 3900, 3900, 3900, 3900, 3900, 5000, 5000, 5000, 4000, 4100, 3900, 3900, 3900, 3900 }

Output:      Value = { 3900, 5000, 4000, 4100, 3900 }

Freq = { 6, 3, 1, 1, 4 }  

 

There is a post out there that tells me how to generate a histogram, however, I need it slightly modified so that it doesn't search through the whole array, but rather just keeps a running counter and insert it into a new array everytime it finishes counting how many values were in that set.

 

Here is my start to the solution (attached as a PNG and a VI)

Download All
0 Kudos
Message 1 of 7
(3,606 Views)
Solution
Accepted by topic author ruthnan

Hi ruthnan,

 

it's a simple counting you need:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,600 Views)

Hi GerdW,

 

What is the true case here? I ran the code, but it didn't work as expected, maybe since I couldn't see what the true case is.

0 Kudos
Message 3 of 7
(3,589 Views)

Okay - I kind of got it working, but how do I only add array elements when it has finished counting? Right now, it increments for every index. I want to create a new array, that is not necessarily the size of the original array.

Download All
0 Kudos
Message 4 of 7
(3,587 Views)

Gerd's image is a snippet.  That means you can drag the image and drop it into a block diagram.  Then you can see what the true case has.

 

The main difference I see between his and yours is the location of the Build Array function.

Message 5 of 7
(3,569 Views)

I see!! Thank you very much, RavensFan and GerdW! I was trying to drag from Google Chrome, but it was not working, so I dragged and dropped the snippet from IE. I will modify the code today.

0 Kudos
Message 6 of 7
(3,551 Views)

I think only IE handles the image properly.  Maybe another browser.  Chrome and I think Safari have problems.

 

With the browsers that have problems, if you save the image to your computer, then you can drag and drop that file to your block diagram.

0 Kudos
Message 7 of 7
(3,549 Views)