LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to accumulate data in array?

Solved!
Go to solution

I made a program aimed to simulate the intensity of light when many light bulbs are put together. I have intensity data of one bulb in xls.-files. So, I want to program to work as follows.

 

  1. Open the xls.-file and get the data.
  2. Put the data into different positions. I put one data set (one bulb) in each excel sheet. //: This is to simulate putting the bulb in different places.
  3. Sum the data in the same cell across the different sheets.

 

My problem is this program running too slow. How should I improve this program? I have an idea to make a big array and accumulate data in that array. However, I do not know how to do it. I can only use [Insert Into Array Function] and [Replace Array Subset Function], which are not suitable for my purposes.

 

Please accept my apologies for any unclear explanation because I am a real beginner. I would sincerely appreciate all your comments, suggestions, and hints. Thank you in advance.

Download All
0 Kudos
Message 1 of 12
(2,098 Views)

Here is the updated program.

0 Kudos
Message 2 of 12
(2,091 Views)

Hello PuriK,

 

Could you please provide a .xls file with some data to simulate ?

 

One question to start :

-Why doing two "New report" actions ? That could fit into a unique flow.

 

0 Kudos
Message 3 of 12
(2,061 Views)

Thank you for your comments. I improved my program by using only one "New report" action. Please see the updated program attached here.

 

I also attached the .xls file here.

 

Thank you again for your help. I am looking forward to your response.

Download All
0 Kudos
Message 4 of 12
(1,980 Views)
Solution
Accepted by PuriK.

Hello PuriK,

 

To avoid race condition I've put the Excel add worksheet into your main report.

I've tested with 20 for the number of LED and it generates 400 sheets (I guess it works as expected).

LED_Pitch_custom.png

 

Now if I follow your orignal post you would like to sum data from SheetX cell A1 with SheetY cell A1 and so on...

 

You could do it by reading all Excel sheet and then add arrays but it does not seem a good idea to me.

 

An other way is to generate 3D array in LabVIEW by generating 2D arrays of lenght X + number of LED by width Y + number of LED. Then you fill the holes with zeroes and sum up 2D arrays.

Here below something I tried, it can be optimized for sure, but please look if it fits your need.

 

LED_Pitch_custom_Varray.png

Message 5 of 12
(1,956 Views)

Hello Defaphe,

 

Thank you again for your help. It saves me!

According to your ideas, I use them to improve my program.
Here is the final program. It works fast and effectively.

 

I truly appreciate your help!

 

LED pitch 20220113_5.jpg

 

0 Kudos
Message 6 of 12
(1,915 Views)

Still seems highly convoluted, randomly mixing I64, I32, and DBL for indices. Why do you think you need to initialize the same 2D array in the innermost loop and once outside the loops? Wouldn't once outside the loop be sufficient? I have the nagging feeling that this all could be greatly simplified and made more readable and efficient in the process. try it!

 

Also note that you are using insert into array instead of replace array subset, meaning that at the end, your output array will be twice the size for no reason. (Insert into array will add a page, shifting all other pages up in memory.)

Message 7 of 12
(1,475 Views)

Can you replace the "raw data" with a diagram constant (create an indicator on that 2D array, run your VI so the indicator contains your data, right-click the terminal...create constant) and fill correct default value in all controls (select controls...edit..make current values default). Then reattach.

 

 

0 Kudos
Message 8 of 12
(1,465 Views)

So going back to your original drawing, here's how you would do the algorithm described in the picture (the picture seems wrong, though. There is no 65x65 or 10x10, etc and the center output should probably be 10, not 12). You can easily modify it for you specific purpose (e.g. step size, etc.).

 

altenbach_0-1656504077603.png

 

(It could even be done with one FOR loop, though. Not shown. Several performance enhancements could be made)

0 Kudos
Message 9 of 12
(1,452 Views)

@altenbach wrote:

(It could even be done with one FOR loop, though.)


Here's one possibility:

 

altenbach_1-1656504546523.png

 

 

(Also note that you might be able to do all this as a simple 2D convolution, of course.)

 

Message 10 of 12
(1,451 Views)