07-04-2018 11:42 AM
Hi,
I'm struggling with a piece of program that don't really know how to implement. I have carried out an experiment and I have designed a tool in Labview that analyses the signals coming from many different sensors and results in a 2 different matrices, one for natural frequencies and another one for damping. Those 2 matrices are related so that element ij of each matrix is the natural frequency and the damping of a calculation process.The same natural frequency could appear several times in the matrix and I wanted to count how many times each frequency appears, since this is real data there's noise and the values are not exactly equal, I defined a 1% range which is acceptable for me to assume two freq are the same.
My first idea was to initialize a matrix (A) the size of the frequency matrix, and taking the first element of the frequency matrix as a seed, compare it with the rest of the elements, if the difference is less than 1% I save the value if not, I update A with a "1" in the same location of the element in frequency. This way once I compared all the elements, I end up with a vector of all the values within 1% of the first element and a matrix A which has "1" where values >1% exist in frequency matrix.
I'm not sure if this is the right path to follow but any suggestions will be very welcome!
Thanks!
07-04-2018 11:55 AM - edited 07-04-2018 11:57 AM
We don't even try to debug pictures, so please attach the actual VI. Make sure that the controls contain some typical default data so the VI is ready to produce some results when run.
None of your operations are matrix specific, so I would start by just using plain 2D arrays instead. (In LabVIEW, a matrix is a special typedef'd 2D array mostly designed for linear algebra operations).
07-04-2018 12:08 PM - edited 07-04-2018 12:10 PM
Just looking at your image, there are quite a few questionable code parts. For example in the while loop you are comparing two matrices over and over, but the result will never change. The compiler will actually move that before the loop as loop invariant code. This also means that if the comparison is FALSE, the loop will never stop, brunring 100% of at least one CPU core doing the same thing over and over forever. We cannot see what's in the TRUE case, so all bets are off there too. 😄
On the left, why don't you initialize an orange 2D array? Blue is pointless! Instead of "insert into array at the end", you could just use "build array". No need to keep track of the index. (There is even a conditional/concatenating tunnel that would potentially eliminate the entire case structure and shift register stuff. But we don't even know your LabVIEW version, so we don't know if that's a possibility). Why is the matrix wired across the case structure? Is anything happening to in in the other case? If not, the wire belongs outside.
07-04-2018 12:13 PM
Sorry about the picture. Uploaded the VI, I just saved it as it is so ignore the loops on the right now I'm just trying to handle other things.
None of your operations are matrix specific, so I would start by just using plain 2D arrays instead. (In LabVIEW, a matrix is a special typedef'd 2D array mostly designed for linear algebra operations).
Thank you, I'll do that.
07-04-2018 05:53 PM
So, does your VI currently produce the correct result based on the default input or do you want a different result? If so, what result would you expect?
(I'll look at it tomorrow, won't be near a computer for a while)
07-05-2018 04:40 AM
Hi,
Thanks for your help!
I've been working on it tonight and I think it does what it's designed to do.
The loops on the left, produce the location array(0s & 1s) to help me sort the frequencies array in frequencies within a 1% range and the first iteration of the sorted frequency and damping arrays.
The while loop then, goes through the location array looking for different frequencies and inserting them in rows in the frequency array. The end condition is when the location array is = to 0 array so I know there's no more different frequencies in the array. The resulting arrays: Frequency should have a row for each bunch of frequencies within a 1% range; Damping should be arranged as frequency.