How to express inner product of two vectors in Stateflow action language?
Ältere Kommentare anzeigen
I want to compute the inner product y of two vectors u and v (same size, both based on input from Simulink) in Stateflow action language. I have tried
x=ml.transpose(u)
y=ml.(x*v)
but during compilation this results in a coder error "Cannot reshape Local Data 'x' (#...) ([...]) to Local Data 'y' (#...) (scalar) for operator =. Please refer to object (#...)." Apparently, the "ml." notation only works with functions, not with operators such as '*'. Would there be a way to write a product as a function - something like y=ml.product(x,v)?
An alternative might be
x=ml.transpose(u)
y=ml('x*v')
but this requires x and v to be defined in the Matlab workspace, which would mean I have to export them first. This seems to be a rather laborious solution.
Any ideas?
1 Kommentar
Wilfred
am 14 Nov. 2011
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 11 Nov. 2011
1 Stimme
The MATLAB * operator has the formal name mtimes
1 Kommentar
Wilfred
am 14 Nov. 2011
Kategorien
Mehr zu Stateflow finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!