Data is inferred as a variable size matrix, while its specified type is something else.
이전 댓글 표시
Let "x" and "y" be two variable-size vectors. now i have a variable named "z" which is defined as:
function z=func(input)
% some code here
% x,y are not input
z = sum(x.*y')/sum(x);
end
obviously "z" is a double variable. but when i send it as the output of the function i get this error:
Data 'z' (#32) is inferred as a variable size matrix, while its specified type is something else.
I guess Simulink assumes that "z" is variable-size too. I'm stuck at this point. any suggestions?
답변 (1개)
Walter Roberson
2015년 8월 29일
Before the final assignment to z, assign
z = 0;
This will tell Coder that the result is expected to be a scalar double.
댓글 수: 3
Marie Behzadi
2015년 8월 30일
Walter Roberson
2015년 8월 30일
Did you specifically mark a data type for the output signal for the MATLAB Function Block ?
Marie Behzadi
2015년 8월 30일
편집: Marie Behzadi
2015년 8월 30일
카테고리
도움말 센터 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!