How to import matlab function in driving scenario app

I have created a driving scenario using driving scenario designer app, and then exported as matlab functions after some changings i again want to test those changes in driving scenario app. But i don't know with which extensiopn i need to save the file? I am unable to import that scenario/function from matlab to driving scenario app

Answers (1)

Hi,
To test the changes made to a scenario exported from the Driving Scenario Designer app in MATLAB, follow these steps:
Export the Scenario:
  • Export your created scenario to a MATLAB function using the Driving Scenario Designer app.
Modify the MATLAB Function:
  • Open the exported MATLAB function in MATLAB.
Save the Scenario Data:
  • At the end of the function, add the following line to save the scenario data to the workspace:
save("data.mat") % It will save the data to workspace
Launch the drivingScenarioDesigne app:
  • Now Run the below command to open the scenario in drivingScenarioDesigner app
drivingScenarioDesigner(data.scenario) % Here we are trying to load the scenario into drivingScenario app
% please check the scenario object name and modify it accordingly
  • Now you can visualize the changed scenario in "drivingScenarioDesinger" application.
Please refer the below code for reference:
function scenario = createDrivingScenario()
% createDrivingScenario Returns the drivingScenario defined in the Designer
% Generated by MATLAB(R) 24.2 (R2024b) and Automated Driving Toolbox 24.2 (R2024b).
% Generated on: 07-Jan-2025 14:19:08
% Construct a drivingScenario object.
scenario = drivingScenario;
% Add all road segments
roadCenters = [38.2 9.9 0;
37.3 -1.2 0;
30.5 -7.9 0;
27.6 -13.5 0;
29.6 0.1 0];
road(scenario, roadCenters, 'Name', 'Road1'); % Chnaged the Road name to Road1
save("data.mat")
Hope it helps!

Products

Release

R2018a

Asked:

on 27 Mar 2022

Answered:

on 7 Jan 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!