LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

Array to get the values one by one

Hi,

I have one VI in which I have set 2D values which I am getting in one by one using for loop because I need to generate sine wave with varying amplitude .

can I use 1D array in place of 2D?

I have attached the VI.

I am getting problem while using 1D array.

can I use the same thing without using for loop? to get the value one by to generate sine wave with varying amplitude?

Message 1 of 6
(410 Views)

Re: Array to get the values one by one

If I understand what you are trying to do, you need to turn off the Autoindexing on the input tunnel of the outer FOR loop.  But you will will need to supply a value to N to state how many iterations to run through.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 2 of 6
(404 Views)
Solution
Accepted by topic author @mi

Re: Array to get the values one by one

You take 2D array and go left-righ-left

-> 4 10 9 6

7 4 6 5 <-

-> 7 1 2 0

Why you can't use 1D in correct sequence

4 10 9 6   5 6 4 7  7 1 2 0?

And use for loop without reverse.

If you need set of waves, you need for loop.

Message 3 of 6
(401 Views)
Solution
Accepted by topic author @mi

Re: Array to get the values one by one

Your "objective" (i.e. what are you trying to do?) is not clear.  Working from the Inner Loop outward, you generate four sinusoids, one every 5 seconds, of differing amplitudes (set by the 4 elements of an array, which could be a Row of a 2D array or a single Array) and display it in a graph.

The top 2D array example shows the 2D Input Array being "fed", one row at a time, into a For loop that reverses every other 1D "row" before feeding it to the inner "Generate Sinusoids" loop.  Two questions -- why reverse every other row, and why use Modular Arithmetic (as opposed to having a Shift Register initialized to T and reset to its inverted value at the output side, a more intuitive "alternate" signal)?

So now we come to the lower example, where you have a single 5-element (not 4) input array.  Do you want to use the same array multiple times, reversing its order each time?  If so, change the input Tunnel from an Indexing Tunnel to an ordinary Tunnel by right-clicking it and choosing "Disable Indexing" (input Tunnels to For Loops are, by default, Indexing, while input Tunnels to While Loops are, by default, "ordinary" Tunnels.  Both can be changed by a right-click).

Now you have to decide how many times you want to do this.  You can wire the number to the "N" terminal of the For Loop, or you can "do it until I say Stop" by converting the For Loop to a While Loop, and wiring the Stop Indicator.

Bob Schor

Message 4 of 6
(388 Views)

Re: Array to get the values one by one

I do not need set of wave, I only need to apply varying amplitude values to the the function generator and then function generator creates the sine wave with varying amplitude values.

Message 5 of 6
(357 Views)
Solution
Accepted by topic author @mi

Re: Array to get the values one by one

@mi wrote:

I only need to apply varying amplitude values to the the function generator and then function generator creates the sine wave with varying amplitude values.

Then let's greatly simplify your logic.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Message 6 of 6
(350 Views)