- 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 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Arnaud Miege
am 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 Kommentare
Weitere Antworten (2)
Arnaud Miege
am 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 Kommentare
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!