The value returned from getNumInputsImpl method must be a constant value. But the Value is immutable
이전 댓글 표시
Hi,
i get the following error when generating code:
The value returned from getNumInputsImpl method must be a constant value.
Properties used in calculating this value must be Nontunable.
The error occurred for MATLAB System block 'SiL_LUT_1D/MATLAB System1'.
The method:
function num = getNumInputsImpl(obj)
num = obj.Approx.numInputs + 1; % input
end
The propertie numInputs of Approx(ValueClass):
properties (SetAccess = immutable)
numInputs = 0;
end
And obj.Approx is a nontunable Property of the System block. So for my understanding, this value can't change in anyway and should be interpreted as a constant value. Any suggestion on a fix or workaround?
댓글 수: 1
Thomas Kucharczyk
2020년 2월 26일
답변 (2개)
Thomas Kucharczyk
2020년 2월 26일
Honglei Chen
2020년 2월 26일
You said numInputs is nontunable, did you try to use Nontunable in the property defintion? Like
properties (Nontunable)
numInputs = 0
end
HTH
댓글 수: 13
Thomas Kucharczyk
2020년 2월 27일
편집: Thomas Kucharczyk
2020년 2월 27일
Thomas Kucharczyk
2020년 2월 27일
Honglei Chen
2020년 2월 27일
If it's numInputs is nontunable, then you cannot change it once the simulation starts. You can probably update it once in setupImpl.
Thomas Kucharczyk
2020년 2월 27일
Honglei Chen
2020년 2월 27일
I was trying to explain for a nontunable property, you are not supposed to change it in your method. It looks like you are using a property, Approx, to control whether a port should be rendered? If so, I'd suggest you to define Approx as a nontunable property and use that one to return the number of inputs. You probably don't need an extra numInputs property.
HTH
Thomas Kucharczyk
2020년 2월 27일
편집: Thomas Kucharczyk
2020년 2월 27일
Honglei Chen
2020년 2월 27일
I see. You should be able to change Approx as long as the simulation has not started. I don't know the logic behind it but you shouldn't need to use listeners to control number of inputs. You can reference Approximator's properties in getNumInputsImpl too.
HTH
Thomas Kucharczyk
2020년 2월 27일
편집: Thomas Kucharczyk
2020년 2월 27일
Thomas Kucharczyk
2020년 2월 27일
Honglei Chen
2020년 2월 28일
Hi Thomas, sorry I cannot help more without seeing the entire code. If you are willing to provide the complete code, I'd be happy to pass it to the corresponding team to investigate. Alternatively, you can contact the tech support to report the bug too.
Thomas Kucharczyk
2020년 3월 2일
Thomas Kucharczyk
2020년 3월 6일
Honglei Chen
2020년 3월 6일
Good suggestion, I'll create an enhancement request for the team, thanks.
카테고리
도움말 센터 및 File Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!