- 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
6 次查看(过去 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!