02-16-2010 05:38 AM
Hi everyone,
I want to do the following with the help of shift registers:
For an arbitrarty array, I want to subtract one element of the array by its follower for
all array indexes from 0 to n-1.
As an example, for an array "3, 2,1", that should give me "1,1".
I tried to create such a vi (and it should include shift registers) , but it doesnt work as I want..
can someone help please?
02-16-2010 06:07 AM
Three possible methods for you: (with and without Shift / Loops):
Andrey.
02-16-2010 06:11 AM - edited 02-16-2010 06:14 AM
Why do you need shift registers?
What exactly was not working in your understanding?
As much as I understand from your post, you need array as an result. You can not get an array using scalar indicator (as you have did in your vi). Shift registers are not necessary.
Edit: Andrey, how much hands do you have? 😄 I see that I have missed the "-1" for the number of cycles to be used.
02-16-2010 08:17 AM
Well, thanks a lot.
Im totally new to labview.
Now the second option of yours with the shift registers (yes, I need those..): The input is not an array but
a scalar, right?
Further on, what kind of array (method) are you using for the output? Is it a "insert into array"? That didnt work
for me though...
Hmm..
And one last question: Does it matter, if I build the array on the front- or the blockpanel? The icons seem to be
different, so I wondered...
Cheers, Mychelle
02-16-2010 08:23 AM
02-16-2010 08:38 AM
Shift Register is scalar. Input array (it is array) is AutoIndexed (as well as output array). Use input array from your first exercise and combine it with last exercise.
You can place arrays on the front panel as controls or indicators or on block diagram as constants. If array placed on front panel, then it appeared as Terminal on the block diagram, then you can create local variables for according terminal, and if array placed on block diagram - you can't. Like variables and constants in C language.
Andrey.
02-17-2010 04:34 AM
Thanks, that helped a lot.
Still Im encountering two problems:
- For the "insert into array" I am using at the output, it seems that it has to be wired with two arrays as an input..?
If not, it shows me an error.
But if I wire it with two arrays, it will of course show the result twice, as for input "3 4 2" the output would be " 1 2 1 2"
instead of only "1 2". So what can I do?
Regards,
M
02-17-2010 04:54 AM
Why "Insert into Array"??? In the example above "Delete from Array" primitive was used. The first elementh in the output is undefined, therefore was deleted from output.
Andrey.
02-17-2010 07:17 AM
Mychelle,
There are probably as many possible solutions as there are ways of (trying to) interpreting what you are trying to achieve.
Can you tell us what it is that you are trying to do and why you are trying to do this? Maybe if we get that perspective, more adequate solutions can be proposed.
I read the posts, and it sounded like you wanted to work with arrays, meanwhile, you're really dealing with scalars. It might be one or the other or both... So again, what's the purpose of this exercise? Where does the data come from? What form is it in? What are your constraints? What is the expected output.
I'm sure the solution is simple, but will any suggestion be the right one? <- that's the question... 🙂
R
02-18-2010 10:09 AM
Hi,
I just missunderstood Andrejs explanation first - now I got it and it works, but thanks anyways Ray!!
Cu,
Mychelle