12-22-2021 11:24 PM
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.
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.
Solved! Go to Solution.
12-22-2021 11:43 PM
Here is the updated program.
12-23-2021 01:43 AM
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.
01-10-2022 07:13 PM
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.
01-11-2022 02:23 AM
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).
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.
01-13-2022 12:38 AM
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!
06-29-2022 03:59 AM - edited 06-29-2022 04:13 AM
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.)
06-29-2022 04:46 AM - edited 06-29-2022 04:48 AM
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.
06-29-2022 07:04 AM
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.).
(It could even be done with one FOR loop, though. Not shown. Several performance enhancements could be made)
06-29-2022 07:09 AM - edited 06-29-2022 10:23 AM
@altenbach wrote:
(It could even be done with one FOR loop, though.)
Here's one possibility:
(Also note that you might be able to do all this as a simple 2D convolution, of course.)