LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cumsum

Solved!
Go to solution

Hello,

I want to generate a vector that is the cumulative sum of another vector without using a loop. My vector is more than 10^6 in length, and a loop takes forever. I use cumsum in matlab, but couldn't find anything analogous in labview.

Thank you! 

0 Kudos
Message 1 of 9
(4,582 Views)
Does your LabVIEW license make the matlab script node available and do you have Matlab on the computer you will be using? If so, you can use the matlab script node and type the cumsum function right into it. 
0 Kudos
Message 2 of 9
(4,578 Views)

yes, I thought about it, but I was hoping I can do the same easily without using Matlab functions. Otherwise I'll just write the whole program in Matlab.

thanks anyway! 

0 Kudos
Message 3 of 9
(4,574 Views)

Hang around a bit, someone might know better than I would.

 

Here is a link to what cumsum does.

0 Kudos
Message 4 of 9
(4,570 Views)
MathScript also supports that function. Not sure if it's actually going to be faster than LabVIEW code. What does your LabVIEW code look like? Can you post the VI? You may have some inherent inefficiencies in your code.
0 Kudos
Message 5 of 9
(4,566 Views)
Solution
Accepted by topic author abz_999

This works for a 1 d array of a million elements...you will have to mod it a bit for a 2d array but it hardly takes any time at all to execute. You must have some inefficiency in your code. If you need to do either columns or rows, I can mod it a bit for you, but you should try it on your own first using this example.

 

Message Edited by for(imstuck) on 05-14-2010 12:43 PM
Message 6 of 9
(4,556 Views)

Thanks so much, my mistake was to disable indexing in the loop (aghhh...).

thanks all for helping. 

0 Kudos
Message 7 of 9
(4,535 Views)
Should th SR be initialized?
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 8 of 9
(4,513 Views)
Doh, good catch. Yes.
0 Kudos
Message 9 of 9
(4,503 Views)