LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert into 2D array

Hi,

 

I have a small problem with 2D array.

 

I've created a 2D array 16 Rows with 10 Colums.

 

Now I want to insert a single value to a specific location for example (5,10) but when I'm using the insert into array function I can't put 2 values for the row and col,

 

Does anyone have some example ?

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 1 of 9
(5,479 Views)

@kobi_Kalif wrote:

Hi,

 

I have a small problem with 2D array.

 

I've created a 2D array 16 Rows with 10 Colums.

 

Now I want to insert a single value to a specific location for example (5,10) but when I'm using the insert into array function I can't put 2 values for the row and col,

 

Does anyone have some example ?


It sounds like you should be using "Replace Array Subset" instead of inserting new elements to the array, which will resize the array to a larger one.

 

Br,

 

/Roger

Message 2 of 9
(5,477 Views)

Hi,

 

but if i want to resize it ? if i have 10 cols and i want to add a new val at col 11 how can i do that ?

 

EDIT:

 

what i want to do is to acquire 16 samples and add then to my array easch time the loop happens.

 

 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 3 of 9
(5,474 Views)

@kobi_Kalif wrote:

Hi,

 

but if i want to resize it ? if i have 10 cols and i want to add a new val at col 11 how can i do that ?

 

EDIT:

 

what i want to do is to acquire 16 samples and add then to my array easch time the loop happens.

 

 


Acquire the 16 samples into a 1d array.

 

Append the 1d array to the 2d array.

 

If you want to limit the size of the 2d array, consider using a circular buffer:

 

https://decibel.ni.com/content/docs/DOC-20403

 

Br,

 

/Roger

 

0 Kudos
Message 4 of 9
(5,462 Views)

Kobi_Kalif wrote:

but if i want to resize it ? if i have 10 cols and i want to add a new val at col 11 how can i do that ?


You cannot add a single value to a typical 2D array, because all rows need to be the same length. You need to either add an entire column or an entire row as necessary. Adding a new column also means that most other elements need to be shifted around in memory.

 

Do you know the final size of the array? What you typically should do is allocate an array of the final size (e.g. will all NaN), then replace elements as the are acquired.

 


Kobi_Kalif wrote:

what i want to do is to acquire 16 samples and add then to my array easch time the loop happens.


Please be much more specific. Do you want to add a row of 16 elements to your 2D array or a column of 16 elements to your 2D array. What makes the "loop happens"? What is the final size of the array?

Can you show us some code?

0 Kudos
Message 5 of 9
(5,437 Views)

Hi,

 

Thanks for the answer I can't really show the code.... I'll try to explain

 

I have a DAQ system that acquire 16 Samples Analog and Temperature , I don't know the size of the final Array , the system can work 15 min or 3 Hours

in high speed I can get 100 Arrays per Sec.

 

I want to create a single 2D array and to add ROW at each loop cycle.

 

With this array I'm planning to save to file , show on graph and so on....

 

If there is a better way to save samples ( lots of samples ) I'm open to suggestions...

 

Thank you,

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 6 of 9
(5,418 Views)

What you are describing is a very basic LabVIEW program functionality and this forum isn't intended for creating applications for individuals, but to help people with implementation specific details, problems, bugs, issues, etc.

 

It sounds like you can use some of the LabVIEW shipping examples related to data acquisition and file storage:

 

http://www.ni.com/white-paper/7466/en (LabVIEW tutorial)

http://www.ni.com/white-paper/3116/en (DAQ tutorial)

http://zone.ni.com/devzone/cda/epd/p/id/5345 (file storage example)

 

Br,

 

/Roger

 

0 Kudos
Message 7 of 9
(5,412 Views)

Hi Roger,

 

I know what to do and i don't want you to it for me....

 

I just want help with the 2D Array....

 

I have a cluster with 16 samples and i want to insert it to an array as a new row at each loop.

 

My problem is that every time the new Row overrides the old row and so i cant save all the data....

 

-----------------------------------------
Kobi Kalif
Software Engineer

0 Kudos
Message 8 of 9
(5,387 Views)

Maybe something like this?

 

Suggestion.JPG

 

Br,

 

/Roger

Message 9 of 9
(5,382 Views)