Matrix formulation with matrix multiplication and raising to N-power

4 ビュー (過去 30 日間)
wissal zaher
wissal zaher 2022 年 7 月 5 日
編集済み: Steven Lord 2022 年 7 月 5 日
Hey guys,
I'm currently working on designing an MPC controller manually and for some reason I get an error defining a Matrix of 8x7 dimension such as :
B = [0.005;
0.1] and B_tilda corresponding to the new states with a prediction Horizon of N = 7 is in the screenschot attached. I keep getting this error :
I would really appreciate any help.
  2 件のコメント
Torsten
Torsten 2022 年 7 月 5 日
You forgot to include your code.
wissal zaher
wissal zaher 2022 年 7 月 5 日
% B_tilda = [0,B,A*B,A.^2*B,A.^3*B,A.^4*B,A.^5*B,A.^6*B;
% 0,0,B,A*B,A.^2*B,A.^3*B,A.^4*B,A.^5*B;
% 0,0,0,B,A*B,A.^2*B,A.^3*B,A.^4*B;
% 0,0,0,0,B,A*B,A.^2*B,A.^3*B;
% 0,0,0,0,0,B,A*B,A.^2*B;
% 0,0,0,0,0,0,B,A*B;
% 0,0,0,0,0,0,0,B]'

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2022 年 7 月 5 日
編集済み: Steven Lord 2022 年 7 月 5 日
If your B is in fact a 2-by-1 vector:
B = [0.005; 0.1]
B = 2×1
0.0050 0.1000
then you cannot concatenate it horizontally with 0 as they don't have the same number of rows. [SL: removed an accidental repeat of the advice about "same number of rows."] If you defined a variable like this:
Z = zeros(size(B));
then this concatenation would be valid:
M = [B, Z; Z, B]
A = 4×2
0.0050 0 0.1000 0 0 0.0050 0 0.1000
  1 件のコメント
wissal zaher
wissal zaher 2022 年 7 月 5 日
All clear now, thank you for the quick and helpful reply :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeController Creation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by