setScenarioVariable
Description
Examples
Set RoadRunner Scenario Variable Using MATLAB
Create a roadrunner
object, specifying the path to an existing project. For example, this code shows the path to a project, on a Windows machine, located at "C:\RR\MyProject"
. This call assumes that RoadRunner is installed in the default location, and returns an object, rrApp
, that provides functions for performing basic workflow tasks such as opening, closing, and saving scenes and projects.
projectFolder = "C:\RR\MyProject";
rrApp = roadrunner(projectFolder);
Open an existing scenario in the specified project by using the openScenario
function, specifying the rrApp
object and the specific scenario filename
that you want to open as inputs.
filename = "MyScenario.rrscenario";
openScenario(rrApp,filename);
Set the value of a scenario variable. Call the setScenarioVariable
function and pass it the rrApp
object, the variable whose value you want to set, and the value that you want to assign to the variable. For example, this call assigns a value of 17.88 m/s
as the initial speed of the Ambulance
in the scenario MyScenario
.
name = "Ambulance_InitialSpeed"; value = "17.88"; setScenarioVariable(rrApp,name,value)
Input Arguments
rrApp
— RoadRunner application
roadrunner
object
RoadRunner application associated with a project, specified as a
roadrunner
object. This object provides functions
for performing common workflow tasks such as opening, closing, and saving scenes and
projects. rrApp
provides functions that support importing data from
files and exporting scenes to other formats from RoadRunner.
name
— Name of variable to set
character vector | string scalar
Name of variable to set, specified as a character vector or string scalar. If the specified variable does not exist in the scenario, MATLAB® returns an error. For more details on creating variables in a scenario, see Generate Scenario Variations (RoadRunner Scenario).
Example: setScenarioVariable(rrApp,"Ambulance_InitialSpeed",17.88)
sets the initial speed of the Ambulance
vehicle.
value
— Value to assign to variable
character vector | string scalar | logical scalar | numeric scalar
Value to assign to the variable, specified as a character vector, string scalar,
logical scalar, or numeric scalar. This argument specifies the new value of the scenario
variable specified by name
.
Example: setScenarioVariable(rrApp,"Ambulance_InitialSpeed",17.88)
sets the initial speed of the Ambulance
to 17.88
m/s.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
| string
Version History
Introduced in R2022a
See Also
roadrunner
| getScenarioVariable
| close
Topics
- RoadRunner Scenario Fundamentals (RoadRunner Scenario)
- Simulate a RoadRunner Scenario Using MATLAB Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)