Integrate 61 x 3 tabular data using Runge Kutta

1 回表示 (過去 30 日間)
HN
HN 2020 年 5 月 4 日
コメント済み: HN 2020 年 8 月 18 日
I have a 61 x 3 velocity data and wanted to integrate using Rung Kutta integrator? I know how to integrate when I have a function but I am a bit confused when it is tabular data. Integration step is . Data is attached. Any help is apperciated. Thanks

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 4 日
編集済み: Ameer Hamza 2020 年 5 月 4 日
If you are okay with using the built-in function, then use ode45, which is an implementation of the RK (4,5) algorithm.
data = load('angular.velocity.data.txt');
v1 = data(:,1); % First column
v2 = data(:,2); % Second column
v3 = data(:,3); % Third column
time = 0:0.016:0.016*(numel(v1)-1);
IC = 0; % initial displacement is 0
[~,x1] = ode45(@(t,x) odeFun(t, x, time, v1), time, 0);
[~,x2] = ode45(@(t,x) odeFun(t, x, time, v2), time, 0);
[~,x3] = ode45(@(t,x) odeFun(t, x, time, v3), time, 0);
%% plotting
subplot(1,3,1)
plot(t,v1,t,x1);
legend({'Velocity', 'displacement'})
subplot(1,3,2)
plot(t,v2,t,x2);
legend({'Velocity', 'displacement'})
subplot(1,3,3)
plot(t,v3,t,x3);
legend({'Velocity', 'displacement'})
function v = odeFun(t, x, time, vx)
% v = interp1(time, vx, t, 'linear'); % linear interpolation
% v = interp1(time, vx, t, 'pchip'); % pchip interpolation
v = interp1(time, vx, t, 'makima'); % makima interpolation
end
  13 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 5 月 10 日
編集済み: Ameer Hamza 2020 年 5 月 10 日
Value of which variables change with the value of integration? See this example: https://www.mathworks.com/help/releases/R2020a/matlab/ref/ode45.html#bu3l43b to see how to handle parameters which vary with the input variable.
HN
HN 2020 年 8 月 18 日
I need your help in similr problem,
S % 3 by 100 data
W=skew(S) % 4 by 4 marix
dq=0.5*(W*q')'; % have only initial q
I wanted to integrate dq to get q. Can you help me ?

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

その他の回答 (1 件)

darova
darova 2020 年 5 月 4 日
  • YOu can create function using interp1 or spline
  • You can write your own solver
Simple solver Euler method
for i = 1:length(velocity)
position(i+1) = position(i) + dt*velocity(i);
end
  1 件のコメント
HN
HN 2020 年 5 月 5 日
Thank you!

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by