LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace values in an array inside a loop?

Screenshot 2023-04-12 131810.png

 I have 1D array and I want to scan its element, manipulate them accordingly and create a new array with modified values. I came up with this but it only replaces one value at a time instead of replacing them all. If my index is 0, I only replaces first value, when index is 1, it replaces only second. Obvious solution is to perform this outside of for loop and but I can't bring index outside of the loop, it say it different values type. Other than converting indexing variable i and performing subset replacement outside of the loop, is there a simpler solution? Thanks  

0 Kudos
Message 1 of 5
(935 Views)

What you wanted to achieve not able to get exactly your problem, Just Let us know your inputs and expected output value

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 5
(928 Views)

I want my output to be an array with first value "XY" and second "RZ". I'm simplifying, there's a much longer command that I want to append to "X" and "R", so it makes sense to use for loop.

I'd have several strings/variables "A", "B", "C", "D", etc. and I want to get an array with "A4321", "B4710", "C7310", etc. 

0 Kudos
Message 3 of 5
(926 Views)

ArrayIndexing.png

 

If your input is Array you can use this method.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 5
(919 Views)

@John32d wrote:

I want my output to be an array with first value "XY" and second "RZ". I'm simplifying, there's a much longer command that I want to append to "X" and "R", so it makes sense to use for loop.

I'd have several strings/variables "A", "B", "C", "D", etc. and I want to get an array with "A4321", "B4710", "C7310", etc. 


The first step of solving a problem is define it. You have not (yet). And no, you code picture above make absolutely no sense.

 

So you have an array with two elements [XY, RZ] and want to add more elements to that.

 

LabVIEW does not have variables. Where do the strings (A, B, C, D) come from? Are these scalars? Are these in an array of ordered elements? Where do the number come from? (4321, 4710, 7310, etc)

 

What should the final array size be? Do you know that size from the beginning?

0 Kudos
Message 5 of 5
(890 Views)