Main Content

addColumn

Add column to spreadsheet in Safety Analysis Manager

Since R2023b

Description

addColumn(spreadsheet) adds a column to the spreadsheet, spreadsheet, in the Safety Analysis Manager.

example

addColumn(spreadsheet,Name=Value) adds a column or columns to the spreadsheet using one or more name-value arguments.

example

Examples

collapse all

Create a new spreadsheet in the Safety Analysis Manager.

mySpreadsheet = safetyAnalysisMgr.newSpreadsheet;

Add a column to the spreadsheet.

addColumn(mySpreadsheet)

Create a new spreadsheet in the Safety Analysis Manager.

mySpreadsheet = safetyAnalysisMgr.newSpreadsheet;

Add two columns to the spreadsheet.

addColumn(mySpreadsheet,Count=2)

Add a third column between the two columns.

addColumn(mySpreadsheet,Position=3)

Suppose you have an enumeration class named Directions defined on the path, and you want to create a spreadsheet with a column that only allows the enumerations. Create a new spreadsheet in the Safety Analysis Manager.

mySpreadsheet = safetyAnalysisMgr.newSpreadsheet;

Add a column that allows only the enumerations defined in Directions.

addColumn(mySpreadsheet,Type="Directions")

Input Arguments

collapse all

Spreadsheet in the Safety Analysis Manager, specified as a Spreadsheet object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: addColumn(spreadsheet,Type="checkbox") adds a check box type column to the spreadsheet.

Index of the new column, specified as a positive integer. The index of the leftmost column of the spreadsheet is 1. To find the number of columns in the spreadsheet, retrieve the Columns property of the Spreadsheet object used in spreadsheet.

Example: addColumn(mySpreadsheet,Position=2) inserts a new column into the second index of the Spreadsheet object, mySpreadsheet.

Example: addColumn(mySpreadsheet,Position=mySpreadsheet.Columns + 1) adds a column to the rightmost side of the Spreadsheet object, mySpreadsheet.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Number of columns to add to the spreadsheet, specified as a positive integer.

If you do not specify this argument, the function adds one column.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Column type, specified as a string array or cell array of character vectors. The dimension of this argument must match the number of columns that you add. Each element can contain one of these options:

TypeDescription
"text"The column accepts text in the cell values.
"checkbox"The column accepts a logical in the cell values. The values display as a check box.
"derived"The column produces values derived from a formula. To set to column formula, use the setColumnFormula function.
enumeration class name

The column accepts values specified in an enumeration class defined on the path. For more information, see Create an Enumeration Column.

If you do not specify this argument, the function adds a text column.

Data Types: char | string

Column label, specified as a string array or cell array of character vectors. The dimension of this argument must match the number of columns that you add.

If you do not specify this argument, the function adds a column with a predefined label, "LabelN", where N is the number of columns that use the default label.

Data Types: char | string

Limitations

  • After you create the column, you cannot programmatically change the column type. To create a column with a different type, delete the column with the deleteColumn function and add a new column.

Tips

  • Add a column to the leftmost side of the spreadsheet by setting Position to 1.

  • Add a column to the rightmost side of the spreadsheet by setting to the value of Position to the Spreadsheet object Columns property plus 1 or by omitting the Position name-value argument.

Version History

Introduced in R2023b