hello, i want to set the final values of the first function with variable "u" as an initial values for the second function with variable "uc", which can be shown below. my main problem is this term "uc0 = u[end end end end];" what is the correct way.

1 回表示 (過去 30 日間)
close all; clc
kd = 10;
cd = 0.0051;
ct = 10.47;
Tt = 39.5671;
Jt = 13.92;
Jb = 1.1378;
WOB = 1760.9718;
Ls = 0.00597;
Lk = 0.0045;
Ld = 0.183;
Lstr = 0.000019312;
u0 = [0 0 0 0];
tspan = [0 45];
[t,u] = ode45(@(t,u) first_order2(u,kd,cd,ct,Tt,Jt,Jb,WOB,Ls,Lk,Ld,Lstr), tspan, u0);
plot(t,u(:,2),'r',t,u(:,4),'b')
figure
plot(u(:,3)-u(:,1),u(:,4),'g')
%CONTROL
uc0 = u[end end end end];
[tc,uc] = ode45(@(tc,uc) control(uc,kd,cd,ct,Tt,Jt,Jb,WOB,Ls,Lk,Ld,Lstr), tspan, uc0);
plot(t,uc(:,2),'r',t,uc(:,4),'b')
figure
plot(uc(:,3)-uc(:,1),uc(:,4),'g')

採用された回答

Torsten
Torsten 2018 年 7 月 3 日
uc0 = u(end,:);
  3 件のコメント
Torsten
Torsten 2018 年 7 月 6 日
編集済み: Torsten 2018 年 7 月 6 日
The parameter lists for "control" do not fit:
[tc,uc] = ode45(@(tc,uc) control(uc,kd,cd,ct,Tt,Jt,Jb,WOB,Ls,Lk,Ld,Lstr), tspan, uc0);
gives 12 arguments
function duc = control(tc,uc,kd,cd,ct,Jt,Jb,WOB,Ls,Lk,Ld,Lstr,L,wd)
gives 14 arguments.
Stephen23
Stephen23 2018 年 7 月 6 日
@Dirar Aletan: rather than trying to pass so many individual variables, I would recommend that you define those values as fields of one structure. Then you just have one variable to pass around.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by