フィルターのクリア

"Inputs must be floats, namely single or double" when running ode45 for LQ tracker

1 回表示 (過去 30 日間)
Chris
Chris 2018 年 10 月 22 日
回答済み: Walter Roberson 2018 年 10 月 22 日
Using matlab 2017b on windows 10 64-bit I am trying to run ode45 to solve the matrix ricatti equation for a discrete time LQ tracker with fixed final time T. When I run the ode45 I get the error "Inputs must be floats, namely single or double.". Any support on getting a result from ode45 would be incredible.
clc
clear
close all
A=[0 1 0 0;0 -1 -3.22 0.5;0 0 0 1;0 0 17.71 -2.75]; %state matrix
B=[0 0;1 -0.5;0 0;-0.5 2.75]; %input matrix
C=[1 0 0 0;0 0 1 0;0 0 1 0;0 0 0 1]; %output matrix
[An,Am]=size(A);
[Bn,Bm]=size(B);
[Cn,Cm]=size(C);
t0=0;
T=20; %final time (sec)
tspan=[-T,t0]; %for reverse integration of S_dot
%weighing of cost function
W=[1 0 0 0;0 1 0 0;0 0 1 0; 0 0 0 1];
Q=[1 0 0 0;0 1 0 0;0 0 1 0; 0 0 0 1];
R=[1 0; 0 1];
%generate symmetric symbolic matrix S(t)
S_t=sym('S_t',[An,Am]);
S_t=tril(S_t,0)+tril(S_t,-1).';
S_dot=-(S_t*A+A'*S_t-S_t*B*(inv(R))*B'*S_t+C'*Q*C); %differential matrix ricatti equation
S_dot = S_dot(:); %Convert from "n"-by-"n" to "n^2"-by-1 (matrix turned into transpose vector for ode45)
S_T=C'*W*C; %boundary condition @ final time T
S_T=S_T(:); %boundary condition as transpose vector
[time, state]=ode45(@(t,S_t) S_dot,tspan,S_T)
  2 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 22 日
Upload S_dot function
Chris
Chris 2018 年 10 月 22 日
It's stated in the code itself. What are you looking for?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 10 月 22 日
Replace
[time, state]=ode45(@(t,S_t) S_dot,tspan,S_T)
with
syms t;
F = matlabFunction(S_dot, 'vars', {S_t(:)});
[time, state] =ode45(F, tspan, S_T)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by