Borrar filtros
Borrar filtros

view usage of parameters in model.mld

4 visualizaciones (últimos 30 días)
Diana Acreala
Diana Acreala el 8 de Sept. de 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?

Respuestas (3)

Kaustubha Govind
Kaustubha Govind el 8 de Sept. de 2011
You should be able to use:
>> [VarsOut]=Simulink.findVars('MyModel')
See Simulink.findVars for more usage examples.
  3 comentarios
Fangjun Jiang
Fangjun Jiang el 8 de Sept. de 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 el 8 de Sept. de 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).

Iniciar sesión para comentar.


Fangjun Jiang
Fangjun Jiang el 8 de Sept. de 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 comentarios
Diana Acreala
Diana Acreala el 8 de Sept. de 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 el 8 de Sept. de 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.

Iniciar sesión para comentar.


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

Iniciar sesión para comentar.

Categorías

Más información sobre Code Generation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by