Main Content

Create Spreadsheets in the Safety Analysis Manager

The Safety Analysis Manager manages the documents that you use for safety analyses, such as Failure Mode and Effects Analyses (FMEAs) or Functional Hazard Assessments (FHAs). You can create spreadsheets in the Safety Analysis Manager that you can then use to analyze your model.

When you create a spreadsheet, you can manually specify the contents, or create columns that update based on the content of other columns. In this tutorial, you create a simple spreadsheet that takes inputs from two columns and generates the values in a third column.

Create the Spreadsheet

To create a new spreadsheet, open the Safety Analysis Manager. In the Apps tab, click Safety Analysis Manager.

The start menu for the Safety Analysis Manager. You can create a new spreadsheet from here.

Create a new spreadsheet. In the New section, click Empty Spreadsheet. The new spreadsheet has one rows and one column.

A new spreadsheet in the Safety Analysis Manager. The spreadsheet has one row and one column.

Create Spreadsheet Cells

Add three rows and two columns. In the Spreadsheet section, click Add Row three times and click Add Column two times. The rows display their assigned index on the left, and the columns display their labels at the top.

The spreadsheet you created with new rows and columns.

If you add too many rows or columns, you can delete them. To delete a row, click the row index and, in the Edit section, click Delete. To delete a column, click the column label and, in the Edit section, click Delete. If you select multiple rows or columns, you can delete them simultaneously.

You can specify more informative labels for the columns. To change the labels:

  1. Right-click the column label and click Edit Label.

    The context menu that displays after right-clicking the column label. The cursor points to the Edit Label option.

  2. In the Column Label window, in the Edit column label field, enter Text.

    Setting the Column label in the Column Label window.

  3. Click OK. The column label updates.

    The spreadsheet you created with new rows and columns, and an updated column label. The updated column label says Text.

  4. Repeat steps 1–3 for the second and third column. Set the label of the second column to Check Box and the third column to Derived.

    The spreadsheet you created with new rows and columns, and the three columns are updated. The first column label says Text, the second label says Check Box, and the third label says Derived.

Specify Column Types

By default, new columns accept only text in their cells. You can specify four types of columns:

  • 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.

  • Enumeration — The column accepts a value specified in an enumeration class defined on the path. You can select the value from the drop down in each cell. For more information, see Create an Enumeration Column.

  • Derived — The column produces values derived from a formula.

Change the column type of the second and third column. Right-click the column label and click Column Type > Checkbox.

The context menu that displays after clicking the right side of the column label. The cursor points to the Checkbox option.

For the third column, set Column Type > Derived.

The spreadsheet you created with specified column types. The first column label takes text in its cells, the second has a check box for its cells, and the third must derive its value. The value of the third column cells says, Unset!.

Define Derived Values

After setting the column types, you need to specify how the derived column cells generate their values. Set the derived column cells to return different strings based on the values in the other columns.

  1. Right-click the column label and click Edit Formula.

    The context menu that displays after clicking the right side of the column label. The cursor points to the Edit Formula option.

  2. The column formula determines the values for each cell in the column. You write the formula in MATLAB®. You can access the contents of the other cells by using the sfa_columnValue operator. The sfa_columnValue operator retrieves the value associated with the specified column in the same row of each derived cell that the formula evaluates.

    Retrieve the values of the cells from the Text and Check Box columns, and store each of them in a variable. In the Column Formula Editor window, enter this code:

    x = sfa_columnValue("Text");
    y = sfa_columnValue("Check Box");
  3. To specify the value of the cells in the derived column, use the sfa_derivedValue keyword and set it equal to the value that you want. The default column formula sets the cell output to an empty string (since R2024b). Delete the line that defines sfa_derivedValue and specify an if statement where if the cell in the Text column is empty and the check box cell is selected, the derived value is "complete". Otherwise, set the derived value to "incomplete".

    if x ~= "" && y == true
        sfa_derivedValue = "complete";
    else
        sfa_derivedValue = "incomplete";
    end

    The final code in the Column Formula Editor window is:

    The completed script in the Column Formula Editor window

  4. Close the Column Formula Editor window to save the code.

The derived column now calculates the cell values based on the values in the first and second column. To test this, enter text in text column and click the check boxes.

The final Safety Analysis Manager spreadsheet. The derived column says that the first row is complete based on the inputs, while the second and third rows are incomplete.

Save the spreadsheet as get_started_spreadsheet. In the File section, click Save and save the spreadsheet as get_started_spreadsheet in the folder of your choice.

See Also

Related Topics