Best way to specify parameters for a Simulink Embedded Matlab Fcn

I have a fairly large Embedded matlab function that calls 20 other functions that are referenced below in the same Matlab Fcn block. Now, I have a large set of parameters that are used across these 20 functions. What is the best way to specify these variables? I tried supplying them as "Global variables" but then, MATLAB is throwing errors because global variables vary and the dimensions of the matrix based on them is of dimensions [:?x:?]. I tried supplying them as parameters, but then the sub-functions can't access them. I'm now running out of ideas... Please help.
Many thanks!

댓글 수: 2

Defining them as parameters seem like the right thing to do. Are you not passing the parameters into the sub-functions - they should become accessible that way.
Thanks Kaustubha for your quick response :-) My problem is I have too many paramters, now if i pass them as arguments for every function, the code just looks messy. So I'm trying to figure out a more elegant way. Besides, while I developed the code in MATLAB, I gladly put them all as 'global'. Now to change in all the 20 odd sub-functions seems gigantic and messy task. One other thing i'm thinking of is, add another function at the bottom of the code : function varargout = parameterfile and this would hold all the parameters, i shall call this as necessary among various functions. What do you think? Many thanks!

댓글을 달려면 로그인하십시오.

 채택된 답변

surya
surya 2013년 7월 3일

0 개 추천

Finally! %#codegen gives the capability of passing the parameters as a structure and that is neat now.
Thanks!

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Naming Conventions에 대해 자세히 알아보기

제품

질문:

2013년 6월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by