How to set working directory for Simscape?

2 visualizaciones (últimos 30 días)
Srinivas Gopal Krishna
Srinivas Gopal Krishna el 24 de Abr. de 2024
Comentada: Srinivas Gopal Krishna el 24 de Abr. de 2024
I have a fundamental question while working with one of the Simscale examples. I copied the Gamma Stirling Engine example to a different directory. However, all the hyperlinks for the parameters m files are still connected to the original folder. Is this because there is a working directory for Simscale/Simulink ? If so how do I change it to the current directory where the model is.

Respuestas (1)

Brahmadev
Brahmadev el 24 de Abr. de 2024
Editada: Brahmadev el 24 de Abr. de 2024
You can copy the .m files to the new folder as well and then modify the text present in the model as well as the callback function for the example to point to the new .m files.
For modifying the callback function, go to Modelling Tab -> Model Settings and update the PreLoadFcn with the new/copied file names. It is recommended to give the copied files a new name so that they are not shadowed by the .m files in the example folder. See schreenshot below:
You can see which file is being used by running the following command in the command window:
which GammaStirlingEngineParams
Similarily, you can update the text in the model by right-clicking on it and clicking "edit text". Further the hyperlink can be edited by clicking on the and using "Ctrl-K" or right-clicking it and chossing Hyperlink. Change the command to point to the .m files in the new folder. You can also specify the entire path instead of just the name.
edit NewFileName
See screenshot below:
Hope this helps!
  3 comentarios
Brahmadev
Brahmadev el 24 de Abr. de 2024
Editada: Brahmadev el 24 de Abr. de 2024
Is the folder that contains the model file and the .m file added in the path? Usually the folder that stores the .slx file is used as the working directory.
Srinivas Gopal Krishna
Srinivas Gopal Krishna el 24 de Abr. de 2024
Yes, the .slx and .m file are in the same folder.
However, if I manually change the working directory in Matlab to the new folder, the hyperlink 'Open script' works. But the PreLoadFcn still points to the original location.

Iniciar sesión para comentar.

Categorías

Más información sobre Foundation and Custom Domains en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by