Main Content

addReference

Add references to cells

Since R2024b

Description

addReference(spreadsheetCell,referencedCells) creates a reference where the Safety Analysis Manager spreadsheet cell, spreadsheetCell, references the spreadsheet cells, referencedCells.

The spreadsheets must be saved on the path. You must specify different cells in the spreadsheetCell and referencedCells arguments. The cell specified in spreadsheetCell can reference each cell specified in referencedCells only once.

example

Examples

collapse all

Create two Safety Analysis Manager spreadsheets by using the safetyAnalysisMgr.newSpreadsheet function.

mySpreadsheet1 = safetyAnalysisMgr.newSpreadsheet;
mySpreadsheet2 = safetyAnalysisMgr.newSpreadsheet;

Add three rows to each spreadsheet by using the addRow function.

addRow(mySpreadsheet1,Count=3)
addRow(mySpreadsheet2,Count=3)

Add a text column and derived column that have custom labels to the mySpreadsheet2 spreadsheet by using the addColumn function.

addColumn(mySpreadsheet2,Count=2,Type=["text","derived"]...
  ,Label=["Text Column","Derived Column"])

Save the spreadsheets.

save(mySpreadsheet1,"spreadsheet1.mldatx")
save(mySpreadsheet2,"spreadsheet2.mldatx")

Retrieve the SpreadsheetCell objects for the first cell in the mySpreadsheet1 spreadsheet and the first cell in the derived column in the mySpreadsheet2 spreadsheet.

myCell1 = getCell(mySpreadsheet1,1,1);
myCell2 = getCell(mySpreadsheet2,1,"Derived Column");

Create a reference where the myCell2 cell references the myCell1 cell.

addReference(myCell2,myCell1)

Input Arguments

collapse all

Spreadsheet cell to add the reference to, specified as a SpreadsheetCell object. The cell must be in a derived column. For more information on derived columns, see Define Derived Values and Define the Derived Column Formula.

Referenced cells, specified as a SpreadsheetCell object array. The cells can exist in the same or a different Safety Analysis Manager spreadsheet than spreadsheetCell.

Version History

Introduced in R2024b