- 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 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Arnaud Miege
on 19 Apr 2011
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 Comments
More Answers (2)
Arnaud Miege
on 19 Apr 2011
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 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!