How to assign values to all the elements of a matrix in Stateflow action language?

1 回表示 (過去 30 日間)
Wilfred
Wilfred 2011 年 10 月 4 日
回答済み: Muthukumar Ganesan 2022 年 8 月 1 日
I want to assign different values to all the elements in Stateflow action language in one statement. So if A is a 3x3 matrix I would like to one statement like
A=[1 2 3; 4 5 6; 7 8 9]
and not a series of statements like
A[0][0]=1; A[0][1]=2; A[0][2]=3; etc.
According to the help files, the notation [1 2 3; 4 5 6; 7 8 9] can be used to define initial values in the model explorer, but it doesn't seem valid in action language. Any ideas?

回答 (1 件)

Muthukumar Ganesan
Muthukumar Ganesan 2022 年 8 月 1 日
Hi,
For charts with "Matlab" as action language A=[1 2 3; 4 5 6; 7 8 9] can be directly used whereas for the charts with "C" as action language, it is not feasible. One of the workaround would be to use Matlab function inside the chart to accomplish it.
Hope this helps. Thanks.

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by