0
我想在stateflow中将一个数组移位一个元素。Stateflow中的移位数组
在Matlab中,我会用circshift或验证码:
>> x = [1:5]
x =
1 2 3 4 5
>> x(2:end) = x(1:end-1)
x =
1 1 2 3 4
>> x(1) = 0 % New Value
x =
0 1 2 3 4
我如何在Stateflow的动作语言实现这一点。 由于实时目标,嵌入式matlab函数是不可能的。
我尝试这样做:
{x[2:end] = x[1:end-1];
x[1] = 0;}
但那是一个语法错误。 For循环应该是可能的,但事先那很奇怪,我在MATLAB :-)
感谢
对于实时目标,MATLAB函数(您称之为嵌入式MATLAB)是可能的。事实上,这正是他们所设计的。 – am304
@ am304,同意。你也可以考虑为你的Stateflow图表使用[MATLAB作为动作语言](http://www.mathworks.com/help/stateflow/ug/modify-the-action-language-for-a-chart.html) ['circshift'支持代码生成](http://www.mathworks.com/help/coder/ug/functions-supported-for-code-generation-alphabetical-list.html) –