Main Content

getColumnFormula

R2026b

Get derived column formula from spreadsheet in Safety Analysis Manager

Since R2023b

Description

script = getColumnFormula(spreadsheet,column) returns the formula, script, from the derived 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 a derived column to the spreadsheet.

addColumn(mySpreadsheet,Count=1,Type="derived")
setColumnLabel(mySpreadsheet,2,"Results")

Set a formula in the derived column.

script = "x = sfa_columnValue(""Column1"");" + newline + ...
"if x ~= """"" + newline + ...
"    sfa_derivedValue = ""has content"";" + newline + ...
"else" + newline + ...
"    sfa_derivedValue = ""empty"";" + newline + ...
"end";

setColumnFormula(mySpreadsheet,2,script)

Get the formula from the derived column.

formula = getColumnFormula(mySpreadsheet,2)
formula =    
     'x = sfa_columnValue("Column1");
     if x ~= ""
         sfa_derivedValue = "has content";
     else
         sfa_derivedValue = "empty";
     end'

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

Output Arguments

collapse all

Formula from the derived column, returned as a character vector.

Data Types: char

Version History

Introduced in R2023b