Calculation of array

  • Last update:  2021-03-31
  • I. Introduction

    As a report tool, FanRuan often uses the knowledge of arrays when expanding the display. We can consider every expandable cell in the FanRuan report as an array for calculation. When we choose to display the expanded cell list, it is equivalent to directly splitting with "," commas to show the elements of the array.

    Many beginners have some misunderstandings about the operation of arrays, here is a popular science.

    II. Array Definition

    The so-called array is a collection of elements of the same data type arranged in a certain order.

    If a limited set of variables of the same type is named, then this name is the array name.

    The variables that make up the array are called the components of the array, also called the elements of the array, and sometimes also called subscript variables.

    The number numbers used to distinguish the elements of the array are called subscripts.

    Array is a form of organizing several variables of the same type in an orderly form in order to facilitate processing. The collection of these sorted data elements of the same type is called an array.

    III. Array Classification

    An array is a collection of elements, arranged in rows and columns. Arrays are divided into one-dimensional arrays and multi-dimensional arrays.

    An array with a single row or a single column is called a one-dimensional array.

    An array with multiple rows and multiple columns (including 2 rows and 2 columns) is a multi-dimensional array or a two-dimensional array.

    IV. Array Operations

    One-dimensional array and two-dimensional array operation law

    1) Operation of single value x and array

    Execute each element of x and arry separately and return the result, which is the same result as arry's own rank and size. For example: 2*{1,2;3,4;5,6}, perform 2*1, 2*2, 2*3, 2*4, 2*5, 2*6 operations, and return 3 rows and 2 columns The result of the two-dimensional array {2,4;6,8;10,12}, as shown in the following figure:

    222

    The rows and columns in the array are separated by commas and semicolons. A comma indicates a row, and the relationship between the rows is relatively close, separated by a comma; between the columns, the relationship is relatively distant, separated by a semicolon.

    Another example: "A"&{"B","C"} returns {"AB","AC"}. "A"={"B","A","C"}return {FALSE,TRUE,FALSE}

    In other words, the array can be compared, combined, and processed with individual characters or values.

    2) Same direction one-dimensional array operation

    Execute arry1 and arry2 corresponding position elements separately and return the result. It is required that the size of arry1 and arry2 must be the same, otherwise the #N/A error will be returned to the extra part.

    For example: {1;2;3}*{4;5;6} returns {4;10;18}; {1,2,3,4}*{4,5,6} returns {4,10,18 ,#N/A}, as shown in the figure below:

    222

    3) The operation of the different one-dimensional array 

    Each element of arry1 and each element of arry2 respectively calculate and return the result, and get the number of rows of the two arrays * the number of columns of elements, that is, the result of the operation of the array of M rows and the array of N columns is M*N matrix array. 

    For example: {1;2;3}*{4,5,6,7,8}, execute 1*4, 1*5, 1*6, 1*7, 1*8, 2*4, 2*5 , 2*6, 2*7, 2*8, 3*4, 3*5, 3*6, 3*7, 3*8, return {4,5,6,7,8;8,10,12 ,14,16;12,15,18,21,24}

    222

    4) One-dimensional array and two-dimensional array operations

    One direction of a two-dimensional array is the same size as a one-dimensional array. For example, when an M*N two-dimensional array is operated with an array of M rows or N columns, the operation in the same direction is similar to the position corresponding to the one-dimensional array in the same direction. , The operation in the opposite direction is similar to the one-to-one operation between single value and array. If the size range is exceeded, an error value will be returned.

    For example: {1,2,3,4}*{1,2,3,4,5;6,7,8,9,10} That is, 4 columns of one-dimensional array and 2 rows and 5 columns of two-dimensional array operations, column The two array operations in the direction correspond one-to-one according to the position, the insufficient part is filled with #N/A, and the row direction is a one-to-many operation. That is: 1*1,2*2,3*3, 4*4, #N/A *5; 1*6, 2*7, 3*8, 4*9, #N/A *10; return { 1,4,9,16,#N/A;6,14,24,36,#N/A}.

    222

    5) Operations between two-dimensional arrays

    It is required that the size is the same, and the one-to-one corresponding operation of the elements at the same position is performed, and an error is returned when the size is exceeded.

    Example: {1,2;3,4}*{1,2,3;4,5,6;7,8,9} execute 1*1, 2*2, 3*4, 4*5, and the rest Fill in with #N/A, return={1,4,#N/A;12,20,#N/A;#N/A,#N/A,#N/A}

    222


    Attachment List


    Theme: Report Features
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy