Simulink.Parameter Trouble

조회 수: 7 (최근 30일)
Michael Joslin
Michael Joslin 2011년 11월 28일
I have the following function
function CheckA2L(Signal)
%%%%%%Check to see if signal in a2l file
A = ehooks_get_msmtvariable_properties(Signal);
if isempty(A) && strcmp(const_value(1),'K')
Signal = Simulink.Parameter;
Signal.Value = 1;
Signal.StorageClass = 'ImportedExtern';
save('MissingCals','Signal','-append')
end
What I am trying to do is have a new Simulink.Parameter that has the same name as the input to the function then set some properties and save it to an mfile. The only PArameter being made is Signal because it is on the left of the equal sign. How do I create a Simulink parameter with the name of the function input?

채택된 답변

Kaustubha Govind
Kaustubha Govind 2011년 11월 28일
Do you mean that you want to create a Simulink.Parameter object that has the same name as that of the input argument in its caller workspace? In other words, if I invoked your function using CheckA2L(someObj) from the base workspace, you need an object called "someObj" created? If yes, you can use the inputname function as follows:
function CheckA2L(Signal)
%%%%%%Check to see if signal in a2l file
A = ehooks_get_msmtvariable_properties(Signal);
if isempty(A) && strcmp(const_value(1),'K')
Signal = Simulink.Parameter;
Signal.Value = 1;
Signal.StorageClass = 'ImportedExtern';
eval([inputname(1) '=Signal;']);
save('MissingCals',inputname(1),'-append')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by