LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

changing array size without initialize

Solved!
Go to solution

Hello,

 

I'm try to change array size dinamically.

 

I do a calibration of an instrument and from time to time I read 3 parameters and try write to an empty array (not zeroed), and caclulate interpolation polinom according to my measured data,

 

The array must be empty because I use the same array as input to calibration procedure and it can not contain the zero but only measured values and it grow as my measurement flows.

 

I hope that my question is clear,

 

Regards,

Sasa

0 Kudos
Message 1 of 12
(7,617 Views)

Hi

 

What problem you are facing?

According to your question is the array not becoming clear every time?

Please state all the aspects

 

 

0 Kudos
Message 2 of 12
(7,607 Views)

Hi Sasa,

 

your question ins't clear at all...

 

You read 3 parameters. That is fine. But how do you write to an empty array?

Why do you need an empty array "as input to calibration procedure"? When it is empty why should it contain "zero" values?

Why does it grow when you "write to the array"?

 

Please explain in more detail and attach a (sample) VI!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 12
(7,601 Views)

Thanks for very fast reply.

 

how do I write to an empty array ?

Nohow, but I would like to do it. I will try to explain.

 

My calibration procudure accept  X , Y , Z, (never equal to zero ) and calculate interpolation polinom as function Z=f(X,Y).

The array should contain those three values many times and the rest should be empty. I the rest of array is not empty e.g equal to zero because previous initialization then the calibration procedure will take this value and calculate bad function.

One way is to eliminate/delete zero values/row from 2D array and i'm trying that now.

 

 

The better would be that during my measurement I collect data X,Y, Z, in this way.

1. measurement . array=x1, y1, z1

 

2.meas                array=x1, y1, z1

                                    x2, y2, z2

 

3.meas               array=x1, y1, z1

                                   x2, y2, z2

                                   x3, y3, z3

 

and so....

 

As you ca see during my meas. the array grow and keep history.

As my measurement continue  I get more value and more precious interpolation polynom and I can decide on fly which point I should measure again to be even better. I know that array must/should be initialized before becuse of memory allocation but I dont wont to be filled with zero eg it can not be as

                            array=x1, y1, z1

                                      x2, y2, z2

                                      0,  0,   0

 

 

I atach vi, not to much useful

Thanks in advance

Sasa

 

 

 

 

 

 

 

0 Kudos
Message 4 of 12
(7,585 Views)
Solution
Accepted by topic author sasko

Hi Sasa,

 

two possible solutions come to my mind:

1) Use BuildArray to "grow" your array of measurement points. Add only "non-zero" points to the array...

2) Search the forum for threads on "delete elements from array", you will find something like this...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 12
(7,574 Views)

 


sasko wrote:

I atach vi, not to much useful


 

A few comments to your VI.

 

 

  • Use a shift register, not a pile of local variables to keep the array. Why is the array terminal not even connected to the code???
  • Unless you want to display the array on the front panel, you don't even need it if you keep the data in a shift register.
  • You VI cannot easily be stopped because you don't have a stop event.
  • The terminal of latch action booleans should be inside the respective event case.
Attached is a simple example how you could do this more efficiently. (LV 8.0)

 

0 Kudos
Message 6 of 12
(7,554 Views)

Thank you altenbach for sugestions,

 

I do agree that I should use a shift register, only my final program will use case structure. also latch actions can not be inside of event.

 

please find attached a screen

 

thanks again

 

S

 

 

0 Kudos
Message 7 of 12
(7,527 Views)

 


sasko wrote:

I do agree that I should use a shift register, only my final program will use case structure. also latch actions can not be inside of event. 


 

Noooo. This is all wrong! Never hide an event structure inside a case structure. Why do you even need the event structure? There is a 0 ms timeout so it will execute the same event case as if "save data" has been pressed. Are there other event cases?

 

I would strongly recommend to re-think your code once more. There are a lot of useless constructs. Can you attach the VI instead of a picture?

0 Kudos
Message 8 of 12
(7,509 Views)

Hello altenbach

 

Yes , it was another event connected with "highest order" but I give up and did not remove event structure.

 

I attach main VI, the whole project is much bigger

 


Regards

 

S

0 Kudos
Message 9 of 12
(7,499 Views)

Hi Sasa,

 

I was interested to help on your problem - but that interest went drastically down after opening your VI...

 

That is just a bunch of local variables, wires crossing left and right, numerous stacked structures - and all of that several times the size of my notebook screen. No way...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 12
(7,495 Views)