09-12-2012 02:58 PM
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)
Solved! Go to Solution.
09-12-2012 03:20 PM
09-12-2012 04:05 PM
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.
09-12-2012 04:13 PM
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.
09-12-2012 09:30 PM
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.
09-13-2012 09:13 AM
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.
09-13-2012 09:23 AM
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.