2015-04-24 190 views
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 :-)

感謝

+2

對於實時目標,MATLAB函數(您稱之爲嵌入式MATLAB)是可能的。事實上,這正是他們所設計的。 – am304

+2

@ 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) –

回答

0

在評論這兩個答案幫助了很多:MATLAB函數的作品也與我的目標和circshift工作正常。