LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

inserting single element into 2d array

Hola, estoy intentando algo similar, mediante un replace array subset pero en un arreglo boleano. La idea es que funcione como un disparo, le doy la coordenada, disparo y se enciende un led, pero tengo un problema quiero que ese led permanezca encendido hasta el siguiente disparo, si disparo una a una todas las casillas debería mantenerse el estado anterior, les adjunto foto del código para el programa, arriba tengo la entrada de un arreglo boleano. Agradezco sus sugerencias y ayudaCaptura de Pantalla 2020-05-08 a la(s) 12.15.06 a. m..png

0 Kudos
Message 11 of 21
(1,865 Views)

Keep the 2D array in a shift register anchored on the while loop.

 

(Also, the terminal of the OK button belongs inside its event case. You know the number of iterations before the loop starts, so it should be a FOR loop. Of course it would be better to have a state machine instead of stopping the VI at the end, so a while loop is better for that. Where is the terminal belonging to the local variable? Feel free tho attach the VI. we cannot efficiently debug pictures.)

0 Kudos
Message 12 of 21
(1,861 Views)

See if this helps:

 

altenbach_0-1588920602149.png

 

0 Kudos
Message 13 of 21
(1,853 Views)

@AntoineP wrote:

You cannot replace an element of an array if that element does not exist.

 

 For exemple trying to replace element on the 4th row and 1st column of a 3x3 array will result in the same array as output

 

 

     ====>>>>    
Message Edited by AntoineP on 10-09-2008 02:22 PM

That's why I created this.

"If you weren't supposed to push it, it wouldn't be a button."
Message 14 of 21
(1,841 Views)

Thanks Paul. I am going to add that to my secret stash of super-usable vis!

---------------------------------------------
Certified LabVIEW Developer (CLD)
There are two ways to tell somebody thanks: Kudos and Marked Solutions
0 Kudos
Message 15 of 21
(1,836 Views)

@paul_cardinale wrote:
That's why I created this.

I am sure it can be simplified dramatically. 😉

(It could even be expanded to work with arrays of any dimensions. Not shown)

 

altenbach_0-1588957253905.png

 

 

(Sorry, I attached wrong code earlier. Disregard that. Please verify correct operation)

 

 

 

 

Message 16 of 21
(1,827 Views)

Gracias por la respuesta, bueno, estoy esforzándome por entender muchos conceptos, eso se trata de un juego de batalla naval, inicialmente estoy generando los barcos de 5,4 y 3 bits aleatoriamente, sin que se crucen, con algunos problemas cuando cambian de sentido, ese arreglo final quiero compararlo con uno que genere el usuario con esos disparos, te adjunto mi programa y agradezco todas las sugerencias, tengo mucho por aprender. Gracias, por ahora me sale un aviso que el tipo de archivo (.vi) no se admite, no puedo adjuntártelo

0 Kudos
Message 17 of 21
(1,825 Views)

You did not attach anything yet.

0 Kudos
Message 18 of 21
(1,822 Views)

@altenbach wrote:

@paul_cardinale wrote:
That's why I created this.

I am sure it can be simplified dramatically. 😉

(It could even be expanded to work with arrays of any dimensions. Not shown)

 

altenbach_0-1588957253905.png

 

 

(Sorry, I attached wrong code earlier. Disregard that. Please verify correct operation)

 

 

 

 


Here's the whole set, with your improvements.

"If you weren't supposed to push it, it wouldn't be a button."
Message 19 of 21
(1,756 Views)

You technically can't as labview enforces that the other columns be of the same size so you have to put your value into that column and pad the rest with zeros. You can then replace those zeros later if you keep track of where they are with a shift register or array.

0 Kudos
Message 20 of 21
(1,601 Views)