view usage of parameters in model.mld

5 views (last 30 days)
Diana Acreala
Diana Acreala on 8 Sep 2011
Hy to all
I have a question please.
I use my_params.mat for my_params.mdl. How can I see what parameters from my_params.mat are not used in my_params.mdl. Because if there are no parameters used I need to delete them.
Any ideea? Is it ok to use textscan? I do not know exactly how but is this a start?

Answers (3)

Kaustubha Govind
Kaustubha Govind on 8 Sep 2011
You should be able to use:
>> [VarsOut]=Simulink.findVars('MyModel')
See Simulink.findVars for more usage examples.
  3 Comments
Fangjun Jiang
Fangjun Jiang on 8 Sep 2011
+1, Kaustubha! I'd love to have those new OO methods. However, my main work is still in R2007b which does not have it. I think the OP doesn't either based on the error message. Since what version are these methods available?
Kaustubha Govind
Kaustubha Govind on 8 Sep 2011
Fangjun: Oops. The function was introduced in R2010a (see release notes: http://www.mathworks.com/help/toolbox/simulink/rn/bsawhtd.html#bsawljt).
Diana: Sorry, it looks like you may have an older version of MATLAB. :( Unfortunately, I think you might need to follow a manual process like Fangjun suggested. (Unless you can upgrade that is).

Sign in to comment.


Fangjun Jiang
Fangjun Jiang on 8 Sep 2011
I am not aware of a direct or effective way doing it. How many parameters are there in the .mat file? If not many, you can clear one at a time and then do ctrl+D to update the model, if the parameter is used by the model, it will report an error since it's now cleared. Of course, this will not be practical if there are many parameters.
When setting parameters for a model file, .m file is usually used. Using .m file could also add unneeded parameters if proper "house-keeping" is not maintained. The problem for using .mat file to store parameters for a model file is, people usually use save() after model development or simulation to save the .mat file, it is more often that unneeded parameters in the workspace will be put in the .mat file.
  2 Comments
Diana Acreala
Diana Acreala on 8 Sep 2011
Hey... my_params.mat contains a looot of parameters... i just read something about using:
fid=fopen('my_params.mdl')
content=textscan(fid,'%s'..
But I can't concentrate to make this work :)
Fangjun Jiang
Fangjun Jiang on 8 Sep 2011
Are you trying to search the .mdl text file to find the reference of those parameter names? It's unlikely that you can achieve it. You can click menu Edit->Find to do that interactively, but only for known parameter name and one at a time. The real solution is the Simulink.findVars method suggested by Kaustubha. But unfortunately, it's only available at new versionS of MATLAB/Simulink.

Sign in to comment.


Diana Acreala
Diana Acreala on 9 Sep 2011
Do yoy know if it is possible to save automatically a .mdl file in a .txt file in Matlab?
  1 Comment
Fangjun Jiang
Fangjun Jiang on 15 Sep 2011
.mdl file is already an ASCII text file. If you really want to do it, you can do
!copy MyModel.mdl MyModel.txt

Sign in to comment.

Categories

Find more on Programmatic Model Editing 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!