LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

replace an element of a 2d array at any index

Solved!
Go to solution

I have a 2d array and I want to insert it into a[1][0]=5

I tried this but not working!

 

gptshubham595_0-1611290966608.png

 

0 Kudos
Message 1 of 9
(2,099 Views)
Solution
Accepted by gptshubham595

Attach a VI rather than a picture.

 

Clean up the code before posting.  I can't clearly tell which constants go to which inputs in your picture.

 

Save the input data as default.  Tell us what you expect vs. what you are getting.

 

What is a[1][0] supposed to mean?

 

I don't understand why you are taking a 2-D array and reshaping into a 1 x 0 array.  So right there you are generating an empty array.  Nothing downstream of that will make any sense.

0 Kudos
Message 2 of 9
(2,089 Views)

Here a[1][0]=5 means 

if a is 

1 2 3

4 5 6

7 8 9 

 

then replace 1st row and 0th col of a i.e 4 with 5

 

Yes Raven you're right replacing that 1,0 for the first block with the size of that matrix worked!

 

but this is creating an empty array as you said, I tried without that first block too but that has the same efffect

 

Anything can be done to replace just an index?

0 Kudos
Message 3 of 9
(2,082 Views)

Hi gpt,

 


@gptshubham595 wrote:

Anything can be done to replace just an index?


Sure: Use ReplaceArraySubset to replace elements/subsets of an array.

Why do you think you need to place additional functions for that purpose?

 

Your questions shows lack of basic LabVIEW knowledge: in your other thread you already got suggestions to take basic LabVIEW training. Did you?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(2,069 Views)

Yes, I tried from my side and solved this! 

Thank you!

0 Kudos
Message 5 of 9
(2,060 Views)
Solution
Accepted by gptshubham595

@gptshubham595 wrote:

Here a[1][0]=5 means 

if a is 

1 2 3

4 5 6

7 8 9 

 

then replace 1st row and 0th col of a i.e 4 with 5

 

Yes Raven you're right replacing that 1,0 for the first block with the size of that matrix worked!

 

but this is creating an empty array as you said, I tried without that first block too but that has the same effect

 

Anything can be done to replace just an index?


Yes.  As I said, get rid of that Reshape Array function.  Just use Replace Array element!

 

What was your thought process that made you put Reshape Array in there?

0 Kudos
Message 6 of 9
(2,034 Views)

Initially when I was learning I followwe this

Insert Item Into Any Array Index - Discussion Forums - National Instruments (ni.com)

 

 

I saw them using this so I thought to use this

 

 

 

 

0 Kudos
Message 7 of 9
(2,021 Views)

That example is for inserting a new element into the array.  And the resize array is only uses in the one case where the element to be inserted is after the length of the array.

 

You aren't doing that.  You are replacing an array element that already exists.

0 Kudos
Message 8 of 9
(2,015 Views)

Yes!

Already Solved that by the way!

 

Thank You! 

0 Kudos
Message 9 of 9
(2,012 Views)