Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted

06-05-2018 07:13 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Labels:

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?

Solved! Go to Solution.

06-05-2018 07:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Solution

Accepted by topic author @mi

06-05-2018 07:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

Solution

Accepted by topic author @mi

06-05-2018 07:46 AM - edited 06-05-2018 07:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

06-05-2018 09:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Solution

Accepted by topic author @mi

06-05-2018 09:31 AM - edited 06-05-2018 09:31 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@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