06-27-2014 06:05 PM
Dear everyone,
I have a 2D array. I want to integrate along one of the dimensions only which will result a 1D array after integration. Lets say I have a 2D array ((1,2,3), (2,1,3), (4,5,6)). If I integrate along row wih dt=1 it will result a 1D array (6,6,15). One can do so by spilitting the 2D array by 'index array' and then using '1D numerical integration' function. But it will take some time for a big array size to separately integrate one row after another. Is there any way to integrate along each row simultaneously so that it saves time?
Thanks in advance,
Somnath
06-27-2014 06:38 PM
You are actually asking for the sum, not the integral. You don't want the intermediate values, just the result.
You can loop through the 2D array and use Sum Array to quickly sum each line, which is probably the fastest way to do it. Another option is to use IMAQ LinearAverages, which will give you the average of each row. You can multiply by the number of points in each row to get the sum.
Bruce
06-28-2014 12:50 PM
What are you trying to do finally may be there will a direct function
06-28-2014 04:09 PM - edited 06-28-2014 04:10 PM
Basically, I convert image to array, which is a 2D array. Then I want to integrateout one dimension to get a line spectra. So basically its an addition of all elements of a row for a column index. Unfortuntely, I could not find the sum array function or IMAQ liner average VI what Bruce suggested. May be I miised to install portion of IMAQ. It will be very helpful if anyone can help me finding/installing IMAQ linear average VI.
Thank you
Somnath
06-28-2014 04:18 PM
The sum array function is a basic math function on the math palette.
Bruce
06-28-2014 04:31 PM
Hi Bruce,
Math pallet meaning inside mathematics right? May be I am missing something stupid, but I can not find even in giving search in function pallets search option.
Somnath
06-29-2014 09:31 AM
Sorry, Add Array Elements in Numeric palette.
Bruce
06-30-2014 02:37 AM
As suggested add array elements in a direct function that you use. Can you post an image before you convert it into an array?