how to get the path of a .ssc file that relates to your block built by ssc_build.
5 views (last 30 days)
Show older comments
I have a simscape block built using a .ssc file. Both have different names "Block source" and "source.ssc". I would like to know if it is possible to get the source code path from the block. Through code in matlab. I know it is possible by selecting 'source code' in the dialog window of the block but I would like to do it with code. I have also seen that there are toolboxes that could help me, but I want to avoid using them, since I can only use the trial version.
0 Comments
Accepted Answer
Manoj Mirge
on 18 Apr 2023
Hi Paola,
Since the Simscape Component block is general block in your Simulink model, you can use get_param function in your Matlab script to get mask properties of your Simscape Component block. The mask of Simscape Component block will have property named “ComponentPath” which will have value as path of .ssc file used for building corresponding Simscape Component block. After getting path of your .ssc file you can open that file using Matlab script and have access to the source code.
In your case the code you will have to write might look like this:
% If your Similink model name is ‘MyModel’
%If your block’s path is “ MyModel/Block source“
load_system("MyModel")
a=get_param("MyModel/Block source","MaskWSVariables");
% "MaskWSVariables" parameter will have mask variables of your block
% 'a' will be struct array with fileds of Name and Value.
% You can check in struct array ‘a’ to find struct which has Name field of ‘ComponentPath’ and corresponding to that find Value field of that struct.
% variable that will store path of .ssc file
pathofsscfile;
for i=1:length(a)
if a(i).Name=='ComponentPath'
pathofsscfile=a(i).Value;
end
end
Hope this helps.
0 Comments
More Answers (0)
See Also
Categories
Find more on Composite Components 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!