Change Tyre Type from code [Combined Slip Wheel 2DOF]
9 views (last 30 days)
Show older comments
Hello,
I'm trying to sweep parameters in the vehicle dynamic blockset including the block "Combined Slip Wheel 2DOF".
I use the line:
in(idx) = in(idx).setBlockParameter(['PassVeh14DOF/Wheels and Tires/VDBS/' ...
'Tires/MF Tires Vector/Combined Slip Wheel 2DOF'],...
'tireType',Config_Tyres);
Where Config_Tyres is a variable defined before as string, for example
Config_Tyres = "Light passenger car 205/60R15";
I think this is changing correctly the Tyre Type but it's not updating the values as it is done by clicking on the button in this image

How can I "translate" the button in the code line? So it changes the type and updates parameter.
0 Comments
Answers (1)
Ayush
on 7 Sep 2023
Hi Giorgio,
I understand that you want to change the parameter and click a button which would in turn change the other parameters programmatically.
It can be done in the following manner:
1. After loading the model into a MATLAB script, use the “set_param” function to set “tireType” parameter to the desired value (i.e. "Light passenger car 205/60R15"). You can refer to the below documentation to know more about the “set_param” function:
Here is a sample code for reference:
Config_Tyres = "Light passenger car 205/60R15"
set_param("test/Combined Slip Wheel 2DOF","tireType",Config_Tyres)
2. After changing the “tireType” parameter, get the button handle object of the mask by using the “Simulink.Mask.getDialogControl” function on the Simulink mask object. For the button name, right-click on the block and select view mask and find the button with the same prompt message. You can refer to the below documentation to know more about the “Simulink.Mask.getDialogControl” function:
Here is a sample code for reference:
maskObj = Simulink.Mask.get("test/Combined Slip Wheel 2DOF")
buttonHandle = maskObj.getDialogControl('paramOverwrite')
3. Once the button handle is obtained, you can then access its callback function. Using the “eval” function, execute the callback function accessed in string format to update the parameters based on “tireType” parameter. You can refer to the below documentation to know more about the “eval” function:
Here is a sample code for reference:
callbackFcn=buttonHandle.Callback
eval(callbackFcn)
Hope it helps,
Regards,
Ayush Misra
0 Comments
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!