- At the chart level, set the dimension of b & c to 2 and the dimension of out1 to 1;
- At the Embedded MATLAB function level, set the dimensions of b1 and b2 to 2 and the dimension of y to 1.
Calculating Norm(inf) within Stateflow
조회 수: 1 (최근 30일)
이전 댓글 표시
Hey,
I'm not sure if this is a bug, a feature or if I'm doing something wrong. I need to calculate a vector-norm (infinity) from time to time in stateflow.
I have two input-signals x1 and x2, both two rows, one column. When I pass these signals to an embedded matlab-function:
out1=calcnorm(x1, x2)
function y=calnorm(cx1, cx2)
y=norm(cx1+cx2, inf)
I'll get just the addition as a result, (again 2x1-Vector). This is still true if I'm using an embedded Simulink-Function containing an embedded Matlab-Funktion.
I found no limitations concerning norm and stateflow..
Any suggestions?
thanks frederik
edit: I'm working with Matlab R2010b
댓글 수: 0
채택된 답변
Arnaud Miege
2011년 4월 19일
Thanks for the additional comments. Yes, I was using only Simulink and can reproduce the problem in Stateflow. I worked around it by specifying explicitly the dimensions of the various inputs and outputs in the Model Explorer:
It should work after that.
HTH,
Arnaud
댓글 수: 0
추가 답변 (2개)
Arnaud Miege
2011년 4월 19일
I have tried it with a MATLAB Function block (new name for Embedded MATLAB block in R2011a) and it works fine. I don't think you need the first line of the code though. Here's the code I used:
function y=calnorm(cx1, cx2)
%#codegen
y = norm(cx1+cx2, inf);
end
The %#codegen pragma is specific to R2011a, it replaces the %#eml in previous releases. I get a scalar output with the inf norm of the sum of the two input vectors.
HTH,
Arnaud
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!