LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace Multiple Array Subsets

Solved!
Go to solution

I have a 1-D array which I want to manipulate.

 

I want to replace the n'th element to the nth + j element with zero's ... and repeat this replacement at integer multiples of n.

 

So for example if n = 5 and j = 2,  starting with an array of 1's then after manipulation the array would look something like:

 

1,1,1,1,1,0,0,0,1,1,0,0,0,1,1,0,0,0,1,1, etc.

 

So n = 5 to n = 7, n = 10 to n = 12, n = 15 to n = 17 .... etc equals Zero.

 

I'm setting the value of n and j with controls on the front panel.

 

I'm coming from a Matlab backround and slowly getting into Labview.

 

Appreciate the help !

0 Kudos
Message 1 of 23
(4,683 Views)

This is a very simple problem. What have you written so far? We can either give you a fish or teach you to fish.

0 Kudos
Message 2 of 23
(4,678 Views)

Hey cool, I've have been fishing ; )

 

Absolutely agree simple problem, getting around how to implement in Labview is the fun bit !

 

I've tried 'insert into array.'  The index can be set to n and the subsquent elements be set to zero.

 

Can look at the output and see it's replacing the first set.Have this done manually so to speak.

 

How to implement a for loop to replace multiple integer sets and make the lenght I'm replacing dynamic (the j in my example).

 

The 'insert to array' context help shows  (from my understanding) you can insert an array at multiple points. When using it I only get one index insertion point option. Also the subset array one is inserting needs to be built to lenght (j - n). 

 

It's the dynamic side of things I'm having difficulty with.

 

Perhaps this methodology I'm using is wrong ??

 

Thanks,

 

Joe

0 Kudos
Message 3 of 23
(4,673 Views)

perhaps you should consider going through some LabVIEW tutorials   http://www.ni.com/academic/students/learnlabview/

 

it is no different solving this problem in LabVIEW as in any other programming language

 

the algorithm is what matters

 

and, oh, yeah, we want to see your attempt with a VI

 

 

 

 

0 Kudos
Message 4 of 23
(4,671 Views)

This is what I have so-far ...

 

Making the "insert into array" dynamic in relation to multiples of "n" and making the "insert into array" variable lenght (j as in my example) is where I'm at

 

Attempt_1

0 Kudos
Message 5 of 23
(4,667 Views)

Image came out abit small so ...

 

Attempt_1

0 Kudos
Message 6 of 23
(4,665 Views)

First, that is not a VI; that is a graphics file.

Second, since your problem is that you don't know how to process the 1D array, why are you throwing all that extraneous stuff in your program?

Start with a simple VI with an array of constants and see if you are able to come up with the algorithm for processing that array of constants.

 

 

0 Kudos
Message 7 of 23
(4,662 Views)

Ok,

 

After many attempts to manipulate the arrays I couln't get it to work so I ended up using mathscript to do the job:

 

Mathscript Solution

 

 

In terms of using the labview functions I got to the point where I can insert any array of size j at any location n. To insert the array of size j at multiple locations at integer multiples of "n" I'm still having difficulty with. 

 

I really would appreciate some guidance at this point, I have the mathscript solution working and would really like to know the "labview solution".

 

Attached is the VI.

 

I have been fishing for the day ; )

 

 

0 Kudos
Message 8 of 23
(4,634 Views)
Solution
Accepted by topic author Joe_Le

@Joe_Le wrote:

I really would appreciate some guidance at this point, I have the mathscript solution working and would really like to know the "labview solution".


As you will see, a LabVIEW solution will be significantly simpler. The most important part would be to learn about shift registers. These are one of the core tools. 😄

 

Here's a very rough 2 minute draft. Modify as needed. Of course you would substitute your real array and use array size to get the size. See how far you get. 😉

 

 

 

Download All
Message 9 of 23
(4,628 Views)

Much appreciated !!

 

I'm looking forward to trying it out !

0 Kudos
Message 10 of 23
(4,624 Views)