solving state space using ode45

4 ビュー (過去 30 日間)
Basetsana Sebolao
Basetsana Sebolao 2021 年 5 月 12 日
コメント済み: Basetsana Sebolao 2021 年 5 月 12 日
Hello Everybody
I am trying to solve a state space equation using ODE45 so that I can plot my states. My equation is of the form idot=Ai +Bv, the dimensions are [4,1]=[4;4]*[4,1]+[4,4][4,1]
When I run the code, I get " errors in 'sys' " but I dont know how to fix them. I have attached a picture of my code. Please kindly assist, thank you in advance.

採用された回答

Walter Roberson
Walter Roberson 2021 年 5 月 12 日
You are trying to run sys() without passing in values for t or i . sys() then fails when it needs to use one of the input variables.
You might possibly be pressing the green Run button. When you use the Run button, unless you take special steps, MATLAB will run the function without passing anything in to it.
When you run a function that has input arguments, MATLAB never pokes around looking in calling environments to see whether it can find a variable with a matching name. You must pass values to the function explicitly if you want the function to process the inputs.
  5 件のコメント
Walter Roberson
Walter Roberson 2021 年 5 月 12 日
Your A is 4 x 4 and you use .* which is element-by-element multiplication, so you get a 4 x 4 output.
If i is 4 x 1 then you should use A*i to get a 4 x 1 result, and likewise the other multiplication in the expression would have to be * instead of .*
Basetsana Sebolao
Basetsana Sebolao 2021 年 5 月 12 日
ohh I see, thank you very much!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by