Main Content

refreshDerivedValues

Recalculate values in spreadsheet derived columns

Since R2024b

Description

refreshDerivedValues(spreadsheet) refreshes the calculations performed in the derived columns in the specified Safety Analysis Manager spreadsheet. Use this function to recalculate the derived values if you update an externally called function in a derived column.

example

Examples

collapse all

This example shows how to refresh derived cell values after you update an externally called MATLAB® function.

Inspect the Spreadsheet

Open the Safety Analysis Manager spreadsheet, myRefreshedSheet.

mySheet = safetyAnalysisMgr.openDocument("myRefreshedSheet.mldatx");

The Calculation column calls the external MATLAB function, myCalculationFunction, to multiply the values in the Input 1 and Input 2 columns, and outputs the result.

The myRefreshedSheet spreadsheet. The spreadsheet has three columns and three rows. The Calculation column multiplies the values in the Input 1 and Input 2 columns together. The Calculation column is grey, and the others are white.

Open the myCalculatorFunction MATLAB file to view the code.

open("myCalculatorFunction")
function output = myCalculatorFunction(x,y)
    output = str2double(x) * str2double(y);
    output = num2str(output);
end

Update Calculations and Refresh Spreadsheet Cell Values

Change the myCalculationFunction function to add the two numbers.

function output = myCalculatorFunction(x,y)
    output = str2double(x) + str2double(y);
    output = num2str(output);
end

Save the function and return to the Safety Analysis Manager spreadsheet. The cell values are not updated. To call the updated function and recalculate the cell values, refresh the cell values by using the refreshDerivedValues function.

refreshDerivedValues(mySheet)

The spreadsheet updates the calculated values in the Calculation column.

The myRefreshedSheet spreadsheet. The spreadsheet has three columns and three rows. The Calculation column adds the values in the Input 1 and Input 2 columns together. The Calculation column is grey, and the others are white.

Input Arguments

collapse all

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

Version History

Introduced in R2024b