LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert row into 2D array retaining previous values

Solved!
Go to solution

Changing data is entered into a 2D array and also displayed in a table. When hour rolls over the 3 columns of data are held and then new row created. Problem is the row moves down but previous data is not stored. I have tried using shift register but that just auto indexs the rows filling array as loop iterates. It looks a really simple basic problem but going around in circles on this one.....

 

 

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 1 of 10
(5,339 Views)

You posted a picture of your code, that's not very helpful as I can't run it to see what happens.

Are you just wanting to add data to the bottom of the array (i.e. new rows?). You will definitely need a shift register as you need to store the value of the array between iterations.

 

You can use either of the following:

BuildArray.png

(it's a VI snippet, so you can drag it into LabVIEW 2014 or above)


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 10
(5,319 Views)

Thanks for quick reply, unsure what has happened but it is a code snippet only shown as icon?

 

I have modifed code to include yours but it auto indexs through the rows,

 

 

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 3 of 10
(5,311 Views)

What do you mean by 'auto indexs' - you have no auto-indexing terminals?

I really have no idea what you're trying to achieve with this. You initialise the array to a certain size, but then you keep inserting elements (which will make the array grow).

 

Also, you should use the index *before* your case structure, since the array is 0-indexed. That's why you have the blank row at the top.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 10
(5,305 Views)

Using the shift registers increments the rows automatically filling the array.

 

What I am trying to do is only increment the rows when there is a change of hour. So the active row can have data change during its 'hour' and then on hour rollover the next row is selected with previous retained. I have attached a vi in LV 2014 that shows my earlier code using a case statement. Also a code snippet that still shows as icon?

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Download All
0 Kudos
Message 5 of 10
(5,299 Views)

This version now works but is messy..........

 

 

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Download All
0 Kudos
Message 6 of 10
(5,295 Views)

Hi,

 

I think what you want to do is move all the code that involves modifying the array into the "True" case of the case structure. This includes the reading of the column values and appending to the array.

 

See the attached VI.

 

I've removed the pre-loop initialization of the array as I don't think it's needed. You're just concerned with adding to the end of the array, which just requires the "Build Array" function operating on an initially empty 2-D array.

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
0 Kudos
Message 7 of 10
(5,262 Views)

Thanks for reply and vi,

 

I have tried similar with build array but problem is the data on col 2 to 4 inclusive changes and this has to be displayed as it happens.

 

With the case structure it can only 'trap' the data and show totals in the 3 columns on hour change not 'live' so to speak.

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 8 of 10
(5,245 Views)
Solution
Accepted by topic author jack1

In that case, the "Replace Array Subset" function is what is needed to replace the latest row values with the current values from the user interface.

 

On time change, an append occurs.

 

Attached is an update to the VI.

Feel free. Contact me for anything more,
    Pang

You too can be LabVIEW Awesome!
Message 9 of 10
(5,233 Views)

That is brilliant and a lot neater than my efforts!!

 

Thanks Pangvady,

 

Jack

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 10 of 10
(5,223 Views)