LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clear a 2d array

Solved!
Go to solution

Hello everyone,

 

I am generating an array via shift register. My purpose is to add another array(exactly same size with the first one) to this and create a 2d array. 

Like

Minimum Val ;  Data val

       0                         1

       0                         1

 

When i press the record button i write the data so spreadsheet and i erase the first array. How can i erase the last 2d array after each time i pressed record. I dont know why it saves data on that 2d array. How can i erase that array completely. My purpose is, to write data between the last button press and the one before that.

 

Thank you so much! 

deletearray.PNG

0 Kudos
Message 1 of 4
(2,493 Views)
Solution
Accepted by topic author doguhanpala

Hi dogu,

 


@doguhanpala wrote:

When i press the record button i write the data so spreadsheet and i erase the first array. How can i erase the last 2d array after each time i pressed record. I dont know why it saves data on that 2d array. How can i erase that array completely. My purpose is, to write data between the last button press and the one before that. 


You really need to learn the LabVIEW basics: now you stumble upon the initialisation of your shift registers!

 

Simplified your VI:

check.png

Why do you need a FOR loop to create an array of zeros?

Why do you need a sequence structure?

Why do you prepend new data to your arrays? Usually data gets appended…

The Select node makes it easier to read your code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(2,476 Views)
  • Yes, both of your shift registers need to be initialized or their contents will continue to grow forever.
  • You sequence structure has no purpose. Dataflow already fully defines the execution order.
  • You can combine both case structures into one.
  • Learn about "use default if unwired" tunnels.
  • Avoid wires going in all directions.
  • Prepending to an array is significantly more expensive that appending due to memory management issues. You can append and reverse the array once before writing (not shown).
  • You only need one TRUE diagram constant
  • Spend a few seconds cleaning up your front panel. Having the index of an empty array set to 4 can be confusing. Try to keep the index controls at reasonable size, Resize the array containers to actually see a reasonable number of elements. Arrange controls and indicators logically.

Here's how it could look like:

altenbach_0-1575047431845.png

 

0 Kudos
Message 3 of 4
(2,453 Views)

Hello GerdW,

 

Thank you so much for your input. About your questions,

 

"Why do you need a FOR loop to create an array of zeros?"

 

It is a part of my bigger program. I cannot share it all due to confidentiality so i share a similar program. My purpose is to create a file like this.

 

min val, data val(which i read)  max val

5                       10                          15

5                        12                          15

I dont know the size of my array. The user might get 100 or 1000000 data. Minimum value is a constant so i get size of my array and create minimum value array exactly same size. Then i write to the document.

 

"Why do you need a sequence structure?"

 

The real program does more than the version from here. It goes like this. Write headers and stuff, get the data, add the min max val arrays, write the document,test the values,write the result to the document. I use sequence structure there. Since it is part of the program i shared it. I assumed it would affect the answers.

 

"Why do you prepend new data to your arrays? Usually data gets appended…"

 

purpose is the write document like this

 

min val, data val(which i read)  max val

5                       10                          15

5                        12                          15

 

"The Select node makes it easier to read your code…"

 

I did not know that block. I will use it. It is a bit difficult and ugly to use case structures even for really simple choices. Thank you for this information.

 

My algorithm goes like this.

 

User pressed a button and loop started. The data comes from oscilloscope and it is written to an array. When user press the record button, the program gets the data, addes min max and writes to the document. This works fine. When user presses play button again and records the data again, i get the 0's

 

After each record i need to clean the arrays. 

 

Thank you so much for your input and help!

 

 

0 Kudos
Message 4 of 4
(2,386 Views)