Integral of a matrix (x = integration(v)dt) to find x in each time step - how to get it?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ashfaq Ahmed
il 25 Mar 2022
Modificato: Ashfaq Ahmed
il 25 Mar 2022
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 Commenti
Risposta accettata
Torsten
il 25 Mar 2022
Modificato: Torsten
il 25 Mar 2022
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 Commento
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!