Finding the maximum time of ode45

8 ビュー (過去 30 日間)
Collin Parker
Collin Parker 2021 年 4 月 30 日
コメント済み: Collin Parker 2021 年 4 月 30 日
I have a question about my code. I am supposed to find the time at which ymax occurs. I have no idea how to set this up. Thank you.
% Physical constants
m = 45; % kg
l = 10; % m
d = 3.3; % m
rg = 4; % m
I = m*rg^2; % kg.m^2
k = 100e3; % N.m/rad
% Derive the equations of motion and solve them below using ode45
Dz = @(t,z)[z(2);((10*sin(0.1*t)*cos(z(1)*d)-(k/100*(z(1))))/(I+(m*d^2)))];
[t,z] = ode45(Dz,(0:0.1:330),[0;0]);
% Compute the maximum deflection magnitude and the first time of occurence
y = tan(z(:,1)).*l;
ymax = max(abs(y))
tmax =
  1 件のコメント
VBBV
VBBV 2021 年 4 月 30 日
編集済み: VBBV 2021 年 4 月 30 日
Use the index of the matrix y where the max selection occurs

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

採用された回答

Benjamin Großmann
Benjamin Großmann 2021 年 4 月 30 日
The max function is able to output the index of the max value:
[ymax, idx_max] = max(abs(y))
tmax = t(idx_max)
  1 件のコメント
Collin Parker
Collin Parker 2021 年 4 月 30 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by