4 New Ways to Use Array Notation: Copying or Transposing

by Janet Albers | Updated: 07/21/2015 | Comments: 0

Search the Blog


Blog Languages

English
Français (French)


Subscribe to the Blog

Get an email when a new article is posted. Choose the topics that interest you most.


Area / Application

Product Category

Activity

Corporate / News

Enter your email address:



Suggest an Article

Is there a topic you would like to learn more about? Let us know.

Leave this field empty

OS 28

Copying or transposing has become easier with OS 28 (CR6 OS 1). This new operating system enables you to copy portions of an array to a new location, such as when transposing rows and columns.

In this example we start with A(3,2) (3 rows, 2 columns) initialized as

1 2
3 4
5 6

and transpose it to At(2,3)  (2 rows, 3 columns)

1 3 5
2 4 6

You can do this by writing a program like this:


Public A(3,2) = {1,2,3,4,5,6}
Public At(2,3)
Dim i
BeginProg
	Scan (1,Sec,0,0)
		For i = 1 To 2
		'for each column of the source array A()
		'copy the column into a row of the destination array At()
			At(i,-1)() = A(-1,i)()
		Next i
	NextScan
EndProg

To use the new capability of OS 28 (CR6 OS 01) most effectively, there are some rules for you to keep in mind:

  • An empty set of parentheses designates an array-assigned expression. For example, reference array() or array(A,B,C)().
  • Only one dimension of the array is operated on at a time.
  • To select the dimension to be operated on, negate the dimension of index of interest. For example, to operate on the dimension “B,” the syntax is array(A,-B,C).

Note: This new syntax does not affect how repetitions within instructions write to, or read from, variable arrays. To see how to use array notation and repetitions within measurement instructions, watch the “CRBasic | Advanced Programming” video. 

Tip: After updating your operating system, it’s a good idea to check your existing programs to ensure they continue to run as expected.

For more information about, and examples of, multi-dimensional arrays, we have several resources to help you. You can search for the section in your data logger manual titled “Array-Assigned Expression.” The CRBasic Editor Help application in LoggerNet is also a good resource. For example, search for “multi-dimensional arrays”:

Multi-dimensional arrays

Recommended for You: To learn more about OS 28, review the “Powerful New Operating System for CR800, CR1000, CR3000” newsletter article.

Campbell Scientific’s newest data logger operating system (OS 28 for the CR800CR1000, and CR3000; OS 01 for the CR6 datalogger) enables you to use Array Notation in CRBasic multi-dimensional arrays in new ways. This article explored one of these methods—copying or transposing. Three other methods, simple scalinginitializing multi-dimensional arrays, and complex scaling, were discussed in the first three articles in this series. This article concludes the series.

Do you have comments or questions? Feel free to share them.


Share This Article



About the Author

janet albers Janet Albers was a Senior Technical Writer. She enjoyed sharing tips, simplifying concepts, and guiding our clients to a successful project. She had been with Campbell Scientific, Inc. longer than the CR1000, but not quite as long as the CR10X. After work hours, Janet enjoyed the outdoors with her boys and dogs.

View all articles by this author.


Comments

Please log in or register to comment.