Author Topic: 2-dimensional-array to 1-dimensional array  (Read 299 times)

0 Members and 1 Guest are viewing this topic.

Offline DonDiZZy

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
2-dimensional-array to 1-dimensional array
« on: October 25, 2018, 03:00:03 PM »
Hi there,

I am wondering if I could do something like this in VAL3

s1dArray = s2dArray[2]

like this it is not working, but is there a simple way to do so?

Basically i have a program which does whatever it does with 1-dimension of the 2-dim-array. therefore it has a 1-dim-Array defined as parameter or even as local variable.
now i want to pass a specific dimension from my 2-dim-array to that program.

thx for any ideas and replys. cheers.

Offline TygerDawg

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 48
  • Posts: 400
Re: 2-dimensional-array to 1-dimensional array
« Reply #1 on: October 27, 2018, 04:26:28 PM »
I am not aware of any clever function like what you want.
I would approach this problem by:
  • initialize a new 2-dimension array
  • run a for-next loop to take elements from your 1-D array and populate the corresponding vector of the 2-D array
  • do whatever else is needed to populate the remaining vector of the 2-D array

This should take about 2 minutes of coding and a few milliseconds of execution time to accomplish.  :icon_wink:
TygerDawg
Blue Technik
Virtuoso Robotics Engineering
www.bluetechnik.com