LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

consecutive array element differences

Hi,

I working on a portion of a program to determine the logarithmic decrement of a signal.  Since I couldn't find any VI's specifically suited to the task, I'm writing one for the job.  So far I've been able to write the values of the signal's peaks to an array without much effort.

Now I want to determine the log decrement of the values recorded in the array, i.e. I need to determine the value of the second element minus the first, the third minus the second, and so forth.  I've tried doing this with a loop, but I can't seem to wrap my head around the appropriate way to use the shift register to do so (if indeed a shift register is the way to go).  I haven't had much experience with shift registers outside of things like incrementing values, and LabView doesn't seem to have any more complex examples, so I'm really at a loss.  Should be simple, but I've been beating my head against the desk for tooooo long.  So how do I go about this?

Thanks,
YoungTurk


0 Kudos
Message 1 of 8
(4,461 Views)
Yes, the shift register is the way to go. Create the shift register. Wire the current value (index i) inside the loop to the right terminal of the shift register. Then the left terminal will have the i-1 value. You have to plan for the ends of the array as the -1 and n+1 values do not exist.

Lynn
Message 2 of 8
(4,453 Views)

Actually, all you have to do is shift the array by 1 element and subtract the shifted copy fromn the unshifted copy and you have your answer -- no loops, no shift registers...

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 8
(4,449 Views)
May be you means this?

Message Edited by EVS on 08-26-2005 09:41 PM


Jack
Win XP
LabVIEW 6.1, 7.0, 7.1, LabWindows/ CVI 7.1
Let us speek Russian 🙂
Download All
Message 4 of 8
(4,449 Views)
The second one (without the loop) is just the sort of technique I was talking about. Whenever possible, take advantage of the polymorhism of LV's low-level functions and treat arrays as arrays. Depending one what I was doing, I've seen speed improvements of orders of magnitude.
 
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 8
(4,423 Views)
Looks like an elegant solution, Mike and Jack.  One problem, which array VI is shown there?  I'm using LabView 7.1 and I don't see that VI available on the array palette.

Lynn, thank you for explaining the appropriate use of shift registers in this case.  It hadn't ocurred to me to use I to obtain the array element I was after (since I'm used to passing arrays into loops via tunnels).  And of course you're right that the ends of the array have to be considered, which is, I think, why the shifting of the array sounds like the more elegant solution.


0 Kudos
Message 6 of 8
(4,394 Views)

The function is "Delete from array" and it's icon looks different on the function pallete.

You can also literally use the logical shift function to shift the array elements, but then you have to trim off the last element in the result. This approach does that automatically because when you do math on arrays of different sizes, the result is always limited to the number of elements in the smaller of the two arrays.

Mike...

Message Edited by mikeporter on 08-29-2005 01:10 PM


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 7 of 8
(4,377 Views)

@mikeporter wrote:

Actually, all you have to do is shift the array by 1 element and subtract the shifted copy fromn the unshifted copy and you have your answer -- no loops, no shift registers...

Mike...

 

That's brilliant Mike!  Thanks

0 Kudos
Message 8 of 8
(2,830 Views)