Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot 2-dimensional array using one dimension as X-Value and the other as Y-Value

Hi,
 
I have a 2-dimensional array, of type double, and want to plot one dimension (a set of DateTimes) against the other dimension (a set of values corresponding to each DateTime). All the plot functions only seem to accept one dimensional arrays as arguments. Any idea on how to (a) plot my array or (b) split my array into two seperate 1-dimensional arrays, bearing in mind there could be thousands of values so using loops isn't really an option. My application is written in VB.net.
 
Thanks in advance
0 Kudos
Message 1 of 2
(3,120 Views)

Hi,

As the plot functions only accept 1D arrays as parameters you will have to convert your 2D array to two 1D arrays. Unfortunately there doesn't seem to be a native VB.net function to access just one dimension of an array (or I can't find it). The only alternatives would be to copy the array element by element into two new arrays which you mentioned wasn't an option due to the possible size or copy the memory locations to a new array. Rectangular (each dimension has the same length) multidimensional arrays are stored in one contiguous  block of memory with dimensions stored one after the other. Because of this you could directly copy a memory range that would be the first dimension in the array and then repeat for the other dimension. Bellow is a link to an example that converts a 2D array to a 1D array, you could use these principles to perform the functions you need.

http://www.freevbcode.com/ShowCode.asp?ID=3977

Regards

Jon B
Applications Engineer
NIUK

0 Kudos
Message 2 of 2
(3,087 Views)