08-02-2013 02:22 PM
Running LabVIEW 2010 on a newer W7 machine. The attached code seems to run dog slow and I'm wondering if anyone can give pointers on how to speed it up?
Thanks.
08-02-2013 02:36 PM - edited 08-02-2013 02:43 PM
Hi Rick,
all I did was to replace your "Array" local variables by shift registers. Can you imagine the speed increase?
Main problem is the use of local variables of big arrays. Each time you write to the local LabVIEW has to copy data, move the copy to the actual indicator and sometimes even refresh the indicator. As you only need the result of your loop and (probably) are not interested in any intermediate steps while running you should only refresh the indicator once after the FOR loop!
Rename attachment from *-vi to *.vi, still trouble with attachment in the forum...
So now for the real thing:
This one does basically the same as your VI, but faster. All you have to do is to index the columns you need...
("Faster" means like 100s to 0.1s :D)
08-02-2013 03:05 PM
Your other problem was that you were using Insert Into Array when you should have been using Replace Array Subset. So instead of working on your arrays in place, you kept growing your arrays.
But as Gerd already state, just use the Spreadsheet String to Array function. It has been one of my mostly used functions this last year.
08-02-2013 04:10 PM
Yes, changing to shift registers and fixing the Replace Array Subset did speed it up quite a bit. Thanks. I have a question on the Spreadsheet to Array function. I have attached how I think it should work, and I just want to verify. The string is made up of lines that each hold 3 floating point numbers. I need arrays of the 2nd and 3rd number in each line. How would the 3D array be arranged from that?
08-02-2013 04:24 PM
You want a 2D array. The format should just be "%f" and your delimiter should be "," (no quotes in the actual code).
08-02-2013 04:28 PM - edited 08-02-2013 04:28 PM
Hi Rick,
you have a spreadsheet of data - or in other words you have two-dimensional data aka table aka page.
Where do you expect a 3rd dimension? That would be a cube (or to keep the analogy more like a stack of pages)...
So simply follow my snippet above!
08-02-2013 04:43 PM
@rickford66 wrote:
I need arrays of the 2nd and 3rd number in each line. How would the 3D array be arranged from that?
As others have said, you code is pure gibberish. Use the suggested code mentioned earlier. To get the second and third column from the 2D array, use index array and wire a 1 to the lower index. Leave the upper index unwired. This will give the second column. Now resize index array downward for two outputs and you get the third column there.
08-02-2013 05:35 PM
Of course, what was I thinking. I think I had a brain fart. haha Yes, I want a 2D array. Thanks.
08-02-2013 05:38 PM
BTW Crossrulz, I cannot open your vi because it's saved as a later version of LV. I'm using 2010. Thanks.
08-03-2013 05:42 AM
@rickford66 wrote:
BTW Crossrulz, I cannot open your vi because it's saved as a later version of LV. I'm using 2010. Thanks.
I just saved it in 2009.