- https://www.mathworks.com/help/simulink/slref/getactiveconfigset.html?s_tid=doc_ta
- https://www.mathworks.com/help/simulink/slref/get_param.html?searchHighlight=get%20parameters&s_tid=srchtitle_support_results_1_get%2520parameters
- https://www.mathworks.com/help/simulink/slref/set_param.html
Question about Relative Path Variable definitions
5 次查看(过去 30 天)
显示 更早的评论
Hi,
Where do I find path variable definitions? Such as TARGET_ROOT shown below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1638681/image.png)
I want to use a different relative path for a different .ccxml config file.
Best,
Kevin
0 个评论
回答(1 个)
Saurabh
2024-3-22
Hi Kevin,
I can figure out that you need to set a relative path to the project root for a hardware configuration file.
To address this issue, setting the model's InitFcn callback to execute a configuration script is recommended. Below is an initial version of the code to consider. Modifications may be necessary to ensure it aligns with the project's specific requirements.
cs = getActiveConfigSet(gcs);
% retrieves the active configuration set of the current Simulink model.
ctd = get_param(cs, 'CoderTargetData');
% This line extracts the CoderTargetData property from the active configuration set.
ctd.Runtime.LoadCommandArg = [pwd, '\my_file.ccxml'];
% The .Runtime.LoadCommandArg property of ctd (CoderTargetData) is then set to this full path.
set_param(cs, 'CoderTargetData', ctd);
% Finally, the modified CoderTargetData object (ctd), now containing the updated path to the configuration file, is written back to the active configuration set of the model.
For more information about the functions used you can refer to the following links:
I hope that was helpful.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!