runAnalysis
Syntax
Description
runAnalysis(
executes the scripts
that you define in the default spreadsheet
)AnalyzeFcn
and enabled custom
AnalyzeFcn
callbacks in the Safety Analysis Manager
spreadsheet, spreadsheet
. For more information on callbacks in the
Safety Analysis Manager, see Create Callbacks.
Examples
Analyze Spreadsheet and Add Flags
Suppose you have one Safety Analysis Manager spreadsheet
open, mySpreadsheet.mldatx
, and it has two columns. The first is a
check box column and the second is a text column. You want to write a callback script
where, if the check box for a cell is not selected, you mark the adjacent cell in the text
column with a warning flag.
Retrieve the Spreadsheet
object of the spreadsheet.
mySpreadsheet = safetyAnalysisMgr.getOpenDocuments;
Create the callback code as a string.
callBackString = "for n = 1:sfa_spreadsheet.Rows" + newline + ... " textCell = getCell(sfa_spreadsheet,n,2);" + newline + ... " checkCell = getCell(sfa_spreadsheet,n,1);" + newline + ... " if checkCell.Value == 0" + newline + ... " addFlag(textCell,""warning"")" + newline + ... " end" + newline + ... "end";
The code uses the sfa_spreadsheet
keyword to retrieve the
Spreadsheet
object of the spreadsheet that contains this
script.
Assign the code to the default AnalyzeFcn
callback by using the
setCallback
function.
setCallback(mySpreadsheet,"AnalyzeFnc",callBackString)
Run the callback script.
runAnalysis(mySpreadsheet)
Analyze Spreadsheet with Custom Callbacks
Since R2024a
Suppose you have one Safety Analysis Manager spreadsheet
open, mySpreadsheet.mldatx
, and it has three columns. The first two
columns are check box columns and the third is a text column. You want to write two
callback scripts:
For the first callback, if the cell in the first or second column is not selected, add a warning flag to the cell in the text column.
For the second callback, if neither cell is selected, add an error flag to the cell in the text column.
In this example, execute only the first callback when you analyze the spreadsheet.
Retrieve the Spreadsheet
object of the spreadsheet.
mySpreadsheet = safetyAnalysisMgr.getOpenDocuments;
Create the first callback code as a string.
callBackString1 = "for n = 1:sfa_spreadsheet.Rows" + newline + ... " textCell = getCell(sfa_spreadsheet,n,3);" + newline + ... " checkCell1 = getCell(sfa_spreadsheet,n,1);" + newline + ... " checkCell2 = getCell(sfa_spreadsheet,n,2);" + newline + ... " if checkCell1.Value == 0 || checkCell2.Value == 0" + newline + ... " addFlag(textCell,""warning"")" + newline + ... " end" + newline + ... "end";
The code uses the sfa_spreadsheet
keyword to retrieve the
Spreadsheet
object of the spreadsheet that contains this
script.
Create the second callback code as a string.
callBackString2 = "for n = 1:sfa_spreadsheet.Rows" + newline + ... " textCell = getCell(sfa_spreadsheet,n,3);" + newline + ... " checkCell1 = getCell(sfa_spreadsheet,n,1);" + newline + ... " checkCell2 = getCell(sfa_spreadsheet,n,2);" + newline + ... " if checkCell1.Value == 0 && checkCell2.Value == 0" + newline + ... " addFlag(textCell,""error"")" + newline + ... " end" + newline + ... "end";
Create two custom callbacks of the AnalyzeFcn
callback type by
using the addCallback
function.
addCallback(mySpreadsheet,"callback1") addCallback(mySpreadsheet,"callback2")
Assign the code to the custom callbacks by using the
setCallback
function.
setCallback(mySpreadsheet,"callback1",callBackString1) setCallback(mySpreadsheet,"callback2",callBackString2)
Enable the first custom callback and disable the second by using the enableCallback
function.
enableCallback(mySpreadsheet,["callback1","callback2"],[1,0])
Run the enabled custom callback script.
runAnalysis(mySpreadsheet)
Input Arguments
spreadsheet
— Spreadsheet in Safety Analysis Manager
Spreadsheet
object
Spreadsheet in the Safety Analysis Manager, specified as a
Spreadsheet
object.
Version History
Introduced in R2023b
See Also
Apps
Objects
Functions
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)