10-21-2012 03:17 AM
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 ?
10-21-2012 03:31 AM
@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
10-21-2012 03:43 AM - edited 10-21-2012 03:44 AM
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.
10-21-2012 04:06 AM
@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
10-21-2012 11:53 AM - edited 10-21-2012 11:54 AM
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?
10-22-2012 12:56 AM
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,
10-22-2012 01:13 AM
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
10-22-2012 06:13 AM
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....
10-22-2012 06:27 AM
Maybe something like this?
Br,
/Roger