Main Content

setColumnFormula

Specify derived column formulas in spreadsheet in Safety Analysis Manager

Since R2023b

Description

setColumnFormula(spreadsheet,column,script) specifies the code in the script, script, in the column, column, in the Safety Analysis Manager spreadsheet, spreadsheet. The column must be a derived type.

example

Examples

collapse all

Create a new spreadsheet in the Safety Analysis Manager.

mySpreadsheet = safetyAnalysisMgr.newSpreadsheet;

Add one check box, and one derived column to the spreadsheet.

addColumn(mySpreadsheet,Count=2,Type=["checkbox","derived"])

Set the headings of the columns.

setColumnLabel(mySpreadsheet,1,"Text");
setColumnLabel(mySpreadsheet,2,"Check Box");
setColumnLabel(mySpreadsheet,3,"Results");

Specify each cell in the derived column to output "complete" if the corresponding first column cell has content and the second column check box is true. Otherwise, output "incomplete".

script = "x = sfa_columnValue(""Text"");" + newline + ...
"y = sfa_columnValue(""Check Box"");" + newline + ...
"if x ~= """" && y == true" + newline + ...
"    sfa_derivedValue = ""complete"";" + newline + ...
"else" + newline + ...
"    sfa_derivedValue = ""incomplete"";" + newline + ...
"end";

setColumnFormula(mySpreadsheet,3,script)

Input Arguments

collapse all

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

Column location in the spreadsheet, specified as a positive integer, string scalar, or character vector. Use a positive integer to specify the column index, and use a string scalar or character vector to specify the column by its label. The index starts of leftmost column of the spreadsheet is 1.

To find the number or columns in the spreadsheet, retrieve the Columns property of the Spreadsheet object used in spreadsheet. To find the column labels, use the getColumnLabels function on the Spreadsheet object.

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

Formula to use in the derived column, specified as a string scalar or a character vector. Specify the output of the cell with the sfa_derivedValue keyword, and use the sfa_columnValue operator to retrieve the value of the cell in the row that corresponds to the column with the label, label.

Data Types: char | string

Version History

Introduced in R2023b