Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Aliasing multidimensional arrays


afox18 Nov 17, 2021 09:29 PM

I have a number of soil sensors sending data into an array. For output, I want to divide up the array into 4 sets of measurements: 

' 8 sensors, each returning 2 measurements (VWC in col 1, SoilTemp in col 2)
Public SoilData(8, 2)  

'4 sensors in each of two pits (pit A and pit B)
Alias SoilData(-1, 1)() = VWC_A(4)
Alias SoilData(-1, 2)() = SoilTemp_A(4)
Alias SoilData(-5, 1)() = VWC_B(4) Alias SoilData(-5, 2)() = SoilTemp_B(4)

From my understanding, this code should create four (1 x 4) arrays as follows:

* VWC_A should contain elements (1, 1), (2, 1), (3, 1), and (4, 1) from SoilData

* SoilTemp_A should contan the elements (1, 2), (2, 2), (3, 2), and (4, 2) from SoilData

* VWC_B should contain elements (5, 1), (6, 1), (7, 1), and (8, 1) from SoilData

* SoilTemp_B should contan the elements (5, 2), (6, 2), (7, 2), and (8, 2) from SoilData

However, I'm told that my alias is dimensioned illegally. What am I doing wrong? Is the issue that SoilData(-1, 1)() will generate a column vector, but VWC_A(4) expects a row vector? How would I fix this?


nsw Nov 18, 2021 04:16 PM

I do not think that will work. I believe the Alias will only work within one dimension of an array variable.

I think the simplest method is the following :

Public SoilData(8,2)
Public VWC_A(4), SoilTemp_A(4)

VWC_A(1) = SoilData(1,1)
VWC_A(2) = SoilData(2,1)
VWC_A(3) = SoilData(3,1)
VWC_A(4) = SoilData(4,1)
SoilTemp_A(1) = SoilData(1,2)
SoilTemp_A(2) = SoilData(2,2)
SoilTemp_A(3) = SoilData(3,2)
SoilTemp_A(4) = SoilData(4,2)

Log in or register to post/reply in the forum.