06-21-2017 01:30 AM
Greetings!
I'm very new to LabVIEW software as I've spent around 20 days on it till now. Can someone please help me showing how to extract the element at every 3rd iteration in a 2D array. The rows and coloumns of the array are to be user defined.
I'm reminding of the fact he I don't want to extract the 3rd element of each row or coloumn, I want element at every 3rd iteration, and also the count should continue onto next row. My mentor told me to use Shift Registor but I don't know how to implement it here. Thank you in anticipation.
06-21-2017 02:01 AM
Hi Adi,
you need to provide more information - or more clear information…
how to extract the element at every 3rd iteration in a 2D array.
Which element do you want to 2extract" aka index?
What is an "iteration in a 2D array"?
Why do you only need an element every 3rd iteration (of a loop probably…)?
The rows and coloumns of the array are to be user defined.
So you don't know the array size at edit time? Thanks to that ArraySize function…
I don't want to extract the 3rd element of each row or coloumn, I want element at every 3rd iteration,
Again: which element do you want to index?
Please provide a clear example, preferably in a VI with some default values!
and also the count should continue onto next row.
Which "count" are you talking about?
Why should it "continue to next row"? Why not continue to next column?
My mentor told me to use Shift Registor but I don't know how to implement it here.
So I guess this is homework intended to let you learn LabVIEW.
Why don't you ask your mentor/teacher?
(You may ask here, but please don't expect ready-to-use solutions.)
To learn about shift registers you should go through all those free beginner resources offered by NI on their website!
06-21-2017 02:22 AM - edited 06-21-2017 02:24 AM
Thank you for the response and pointing out my mistakes.
I'll try to elaborate it a bit here.
Here I create a 2D array of random numbers with 5 rows and 7 coloumns (suppose).
The output I'm looking for is a 1D array of elements [8, 3, 3, 10, 8, 5........] and so on. I hope you understood the meaning of element at every 3rd position of iteration.
06-21-2017 02:30 AM - edited 06-21-2017 02:32 AM
ReshapeArray from 2D to 1D, then Decimate1DArray into 3 parts.
Ready…
I hope you understood the meaning of element at every 3rd position of iteration.
So you count all elements row-wise…
06-21-2017 12:51 PM
Thank you so much.
That's exactly the kind of array I needed as output. But can you show me how to do that using a loop and shift registors.
I'd be grateful!
06-21-2017 12:59 PM
06-21-2017 01:32 PM
(Note: you are misusing the word "iteration".)
06-21-2017 08:51 PM - edited 06-21-2017 08:54 PM
For a loop based method, you should Reshape the array as already shown, then you can read the method I gave here yesterday: Saving data after specific increments. That link had a slightly different goal, but still wanted every third element from a 1D array. Hopefully it's obvious which parts you should delete if you're not writing to file 🙂
The snippet is below, but the link above has far more detailed explanation of why I used those functions. You'd want to change the input to the top of the Quotient and Remainder function, since this example was looking for multiples of 3. You want 3rd elements, so use a value that increases by one each iteration. Hint: You don't need a shift register - it's already on the diagram 😉
06-21-2017 10:36 PM
@cbutcher wrote:
For a loop based method, you should Reshape the array as already shown, then you can read the method I gave here yesterday: Saving data after specific increments. That link had a slightly different goal, but still wanted every third element from a 1D array. Hopefully it's obvious which parts you should delete if you're not writing to file 🙂
The snippet is below, but the link above has far more detailed explanation of why I used those functions. You'd want to change the input to the top of the Quotient and Remainder function, since this example was looking for multiples of 3. You want 3rd elements, so use a value that increases by one each iteration. Hint: You don't need a shift register - it's already on the diagram 😉
Missed the specs there cb
06-21-2017 11:21 PM
Jeff·Þ·Bohrer wrote:Missed the specs there cb
I did? Below is my modified snippet, doing the actual task here - I had thought people were avoiding "ready-to-use solutions" at GerdW's suggestion, but it seems there are several to choose from now.
Nice reshape though... very slim. I wonder if it's slower though - does the Reshape Array just alter dimension sizing, whilst your for loop copies into a new array? I don't know...