referenced model dynamic path option?

10 views (last 30 days)
Hi all,
I have a question about referenced models. I use them as components, repetitive function blocks. But I have a path issue. I also use svn and version my work.
For example I have model and referenced models in trunk.
  • ...\trunk}model.slx
  • ..\trunk\referencedModel.slx.
Obviously model used referenced model with path ..\trunk\referencedModel.slx. My problem starts here, if I tag or move model.slx to an another folder, model keeps looking for the referenced model in the ..\trunk\referencedModel.slx (but the model.slx is located at for ex ..tags/v1.0/model.slx. How can I make this path dynamic, for example look into the same folder which model.slx locates. I am sure that there is a easy way which I don't know, otherwise how can big projects can be managed? :)
Thanks in advance.

Accepted Answer

Berkin Birol
Berkin Birol on 19 May 2019
OK, I found the solution. I update this topic in case anyone else has same problem/need.
The solution is, the "matlab project" property, which I just learned from webinar Getting Started With Simulink. If one build a matlab project from a model, the project keeps all paths to all referenced models. If you move the project and models to an another folder, for example checkout to a different PC's desktop, all you have to do is to check dependencies of the model. If the model found any dependent files are missing (well, probably this will occur, since you checkout to an another folder), you just need to right click the missing models and select "Add External File". It automatically adds the file with its dynamic path $\project\etc...
Thanks to the Getting Started with Simulink videos of Priyanka Gotika, MathWorks and Michael Carone, MathWorks.

More Answers (3)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 10 May 2019
Maybe set_param() would be an option in this case to link the model and ref. models: https://www.mathworks.com/help/simulink/ug/control-linked-block-status-programmatically.html

Berkin Birol
Berkin Birol on 10 May 2019
Thank you for your answer, I'll try. But I think there must be an easier way. Is it possible to create a new library and use these 'referenced blocks' from this library as predefined blocks instead of referenced model? I never managed to use user defined libraries :)

Berkin Birol
Berkin Birol on 14 May 2019
Actually, my question and problem is like this:
I created a model with referenced model in C.\Users\Berkin\Desktop\myProject folder, mainComponent.slx and subComponent.slx. As you can guess from names, mainComponent is the main model which uses subComponent.slx as referenced model.
The problem is, when I copy the entire folder (C.\Users\Berkin\Desktop\myProject) to an another path, for example C.\Users\Berkin\Desktop\yourProject, mainComponent looks C.\Users\Berkin\Desktop\myProject folder for the subComponent.slx. I must select the new path of it (because now it is located in C.\Users\Berkin\Desktop\yourProject folder).
How can I adjust these blocks so that mainComponent searches subComponent within its own folder, not with an static adress. This is very bothering me, since I use SVN, get tags etc. As you can imagine, models in tags folder still referencing the component in the trunk, the up-to-date one, not the model in the tagged one. So, when I open the model in tag, it works different. If I checkout to an another computer, it will probably not work etc.
How can I solve this issue?

Categories

Find more on Dependency Analysis in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!