LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

rotate array

Solved!
Go to solution

Hello!

We have an 1Darray with values and we want to rotate/shift the values (3 positions). But everytime it shifts we want to read the array.

For example : we have [1 2 3 4 5 6 7 8 9 10 ] and we want to shift it 3 positions like [10 9 8 1 2 3 4 5 6 7] we want to send this array, read it and then to rotate and read it every time until we get the first array.

Do we have to use loops or we can set it directly?

 

Any answers are welcome!

 

Thank You!

 

0 Kudos
Message 1 of 15
(3,398 Views)

First off, rotating your array by three would result in [8 9 10 1 2 3 4 5 6 7].

 

What did you implement so far? What is it what you are struggling with exactly?

 

Yes, you will use loops to rotate, compare and iterate until your comparison to the original array is true.

 

Is this some kind of homework? The task by itself seems to be rather... strange as rotating until it matches the original array seems to be a Rube Goldberg task.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 15
(3,386 Views)

Hi,

Yes we did a mistake in the example.

We tried it to rotate the array inside a  for loop but what it does is to repeat the same rotation than replacing the new one.Which means that it gives [8 9 10 1 2 3 4 5 6 7] every time.

What we do is communicating with a dmx usb interface which means that every change in the array that we make we should read it and send it to our device.So shifting reading, sending and then again shifting reading, sending until we get the initial array.

 

Here is a part of our Vi with the rotate array function.

0 Kudos
Message 3 of 15
(3,359 Views)

Smiley SurprisedSmiley Surprised

 

Why are you using these many for loops??

 

You can initialize visa once outside the loop and close it outside the loop?

 

I am still not understanding what you are trying to compare

0 Kudos
Message 4 of 15
(3,351 Views)

Sorry, but your code is close to "unreadable" (not only to the fact that we only got a screenshot instead of the VI) and it of course does not perform to your liking.

 

From what i see is that your algorithm isn't build correctly. Can you draw something like a flow chart for your task?

 

This helps you in understanding the following points:

- Which code has to be included in a loop, which not?

- How many loops do you need overall? How often does it/they iterate (each)?

- Which data has to be modified each iteration, which not?

 

Regarding the last question: This defines if the data is passed into a shift register or kept in a simple input tunnel.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 15
(3,346 Views)

Yes the loops are not necessary, we are just playing with the Vi.

We put the Visa inside the loop cause if we put it outside it will read only once and this is the final array and not the stages in between.Or maybe not?

In our case we have an array with 24positions and we have the initial array which is [ 255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] and we want to shift the array 7times with step 3 so next array that we want to send is [0,0,0,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] and so on.

 

 

0 Kudos
Message 6 of 15
(3,343 Views)

Your Rotate

 

your rotate.pngrotate.png

 

 

 

Normal rotate

 

 

0 Kudos
Message 7 of 15
(3,330 Views)

Actually our Vi works but its not automated and we have to manually make changes every time. (We use sequences to repeat our steps).We posted the image cause our Vi is too big and complicated and we just repeat the same things.

Yes we know how this rotate function works but doesnt really solve our problem cause we need to do it 7 times and each time we make a rotation we need to send our array to our device.(these are RGB values).

 

0 Kudos
Message 8 of 15
(3,306 Views)
Solution
Accepted by topic author MAGI2

Why do people always insist on making things way more complicated than it needs to be...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 15
(3,295 Views)

@MAGI2 wrote:

Actually our Vi works but its not automated and we have to manually make changes every time. (We use sequences to repeat our steps).We posted the image cause our Vi is too big and complicated and we just repeat the same things.

Yes we know how this rotate function works but doesnt really solve our problem cause we need to do it 7 times and each time we make a rotation we need to send our array to our device.(these are RGB values).

 



We have to just loop the rotate array then why did you insist on changing the array value then?

0 Kudos
Message 10 of 15
(3,287 Views)