Integral of a matrix (x = integration(v)dt) to find x in each time step - how to get it?

조회 수: 2 (최근 30일)
Dear altruists,
I have these (5x1 size) time steps -
t1 = 5.000;
t2 = 5.005;
t3 = 5.015;
t4 = 5.020;
t5 = 5.025;
For each of these time steps, I have this (8x5 size) velocity matrix -
0.223886255942431 0.766594808762019 0.777477860918720 1.46402363417739 NaN
NaN 0.666581311838176 0.440897758695197 0.786687514042304 NaN
NaN 0.760744913959832 0.726179926996350 1.04378898162688 0.222809516150796
NaN 0.275556537143772 0.805109395242995 0.500274785771561 1.14165961699158
NaN 0.388113337549528 0.895797227421048 0.868957410079128 0.906645475357619
0.514726870663309 1.37194840648291 1.17901149918237 0.267171163532900 0.679251749599892
0.700833065925187 0.843516259310205 0.692695783390200 0.206484971298492 0.773597719024071
0.748304643154520 0.433574718009251 0.551547292426642 0.346941328685530 0.738716957530404
How can I intigrate it (x = integration(v)dt) in such way that I get the position of x in every time step? I mean, I want x1,x2,x3,x4, and x5 :)
Thank you so much!
  댓글 수: 3
Ashfaq Ahmed
Ashfaq Ahmed 2022년 3월 25일
Yes, you interpreted it right. Those are 7 different person's data. There are NaN values in the problem, but they were some other values (say, 0) how would I do the calculation?

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2022년 3월 25일
편집: Torsten 2022년 3월 25일
After replacing the NaN values in the matrix, just do
T = [5 5.005 5.015 5.020 5.025];
A = [0.223886255942431 0.766594808762019 0.777477860918720 1.46402363417739 0
0 0.666581311838176 0.440897758695197 0.786687514042304 0
0 0.760744913959832 0.726179926996350 1.04378898162688 0.222809516150796
0 0.275556537143772 0.805109395242995 0.500274785771561 1.14165961699158
0 0.388113337549528 0.895797227421048 0.868957410079128 0.906645475357619
0.514726870663309 1.37194840648291 1.17901149918237 0.267171163532900 0.679251749599892
0.700833065925187 0.843516259310205 0.692695783390200 0.206484971298492 0.773597719024071
0.748304643154520 0.433574718009251 0.551547292426642 0.346941328685530 0.738716957530404];
X0 = zeros(size(A,1),1);
for i = 1:size(A,1)
X(i,:) = X0(i) + cumtrapz(T,A(i,:));
end
X
  댓글 수: 1
Ashfaq Ahmed
Ashfaq Ahmed 2022년 3월 25일
편집: Ashfaq Ahmed 2022년 3월 25일
Yes, that's exactly what I wanted! Thank you so much Torsten :) You are amazing!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by