LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change elements in an array inside a cluster

Solved!
Go to solution

Hi,

I have this cluster of 2 array elements: X and Y. I'd like to programmatically decrease a couples of elements in the Y array by 1 every time the for loop runs. I'm thinking about using hardcoded indices and the Replace Array Subset primitive to change the elements of the Y array, but then I realized this approach is not working for my program since I want to do the same thing to an array of another cluster at different indices. Is there a way to do this in more generic way?

Thank you for any help!

MV

 

clusters.PNG

 

 

 

0 Kudos
Message 1 of 10
(3,686 Views)

So this is what I came up with so far. It's not generic so I can't use this in case the elements of the array are at different location.

0 Kudos
Message 2 of 10
(3,674 Views)
Solution
Accepted by topic author dmvpdx

You'd turn this into a subVI.  But don't "hard-code" the index.  Make it a control on the subVI connector panel.

 

Then for each array, you run it through this subVI and wire a constant to the input of the subVI.

0 Kudos
Message 3 of 10
(3,666 Views)
Solution
Accepted by topic author dmvpdx

Why are you unbundling the same Y element twice? Once is enough!

Use "in place element" structures to unbundle and replace array elements.

 

Why are you creating these datastructures (array of clusters of arrays with mostly redundant elements) at the autindexing output tunnel. Wouldn't it be sufficient to process everything inside the loop?

0 Kudos
Message 4 of 10
(3,644 Views)

Hi RavensFan and altenbach,

 

Thank you for the replies. As you guys' suggestions I modified my VI a little bit to make it work with different cases, but it's getting a little bit complicated. Would there be a better way to do this?

 


@altenbach wrote: 

Why are you creating these datastructures (array of clusters of arrays with mostly redundant elements) at the autindexing output tunnel. Wouldn't it be sufficient to process everything inside the loop?


I'm trying to do is that I have about 22 band pass filter waveform, all of which have the same shape but different gain and I want to check if the waveform are within the set limit. So I'm creating an array for these waveform, use the auto-index to check it with the limit clusters (there are upper and lower limits) and only the pass band should be decreased by 1 for each iteration. Btw, I'm feeding these limit clusters to the limit specification vi under the waveform palette then use the limit testing vi to check the limit with my filter waveform. 

0 Kudos
Message 5 of 10
(3,628 Views)
  • Does it give the right result?
  • Why is there a 1s wait?
  • You are throwing away the changes from the second iteration because your indicator is before the operation.
  • Why are you overwriting two elements with the same value?
0 Kudos
Message 6 of 10
(3,622 Views)

I did give me the correct result.

 

Maybe the attached vi can better explain what I want to do. I don't need save the graphs. I just want to know if all the waveform pass the limits I set. If it does fail, then save the graph at an image (I haven't implemented this function yet). I put the 3s wait in the for loop just for debugging purpose. This is how one of the output waveform looks like

 


BP filter.PNG

0 Kudos
Message 7 of 10
(3,617 Views)

(posting by phone, cannot look at vi)

 

Why can't you just create arrays of limits and compare the data directly?

0 Kudos
Message 8 of 10
(3,612 Views)

Can you explain more on what you mean by "array of limits"?

0 Kudos
Message 9 of 10
(3,606 Views)

OK, looked at your last VI, which has no resemblance to the previous discussion. (we also don't have any data files!). So what's wrong with using the built-in limit testing?

0 Kudos
Message 10 of 10
(3,603 Views)