Nice algorithm for the evaluation of step functions
Electrical engineering
Last week, I did measurements. And today, I tried to analyse those measurements. The problem: I recorded with a LDS - Nicolet system. And I used Perception for the evaluation. But the functions are quite limited. That’s what I think.
So I exported the recordings to ASCII. Which meant, I had 17 MB for each record. With 7.5 million samples each. And then I needed to find at which point, a step in the digital signal occured (High=10 Volts, Low=0.xxx V). So I imported the records in Scilab. Then I programmed some loops to run through all the records. It took Scilab 40 minutes. So obviously, there was room for improvement. What to do?
1. Create a vector, containing the analogue data of the more-or-less digital signal.
2. Create a second vector, comprising the same data
3. shift the second vector one row upwards
4. Subtract vector one from vector two
5. Divide the resulting vector by 10, and round it to integers
The result is a vector, which only contains -1 (down-step), 0 (no step), 1 (up-step).
6. Create a sparse-vector out of it.
7. Get all the values, which are in the original matrix, at the points of the sparse.
The result is: Instead of 40 minutes, the result was prepared within 10 seconds. But, you need to give Scilab a higher stacksize. By: stacksize(’max’)
If you want to have a look, you can download the file here.


