How can I Integrate on an array with respect to another array

I want to integrate an array which is, acceleration, with respect to another array, which is time to get velocity, then integrate the velocity array with respect to time again to position. Does anyone know how I can do this? Any help will be appreciated thanks.

 채택된 답변

Steven Lord
Steven Lord 2024년 3월 26일

0 개 추천

To integrate data sets use the trapz or cumtrapz functions.
If you had functions to integrate use the integral family of functions.

댓글 수: 5

Both the time and acceleration arrays are functions. Could you explain to me how I would use the integral function to integrate acceleration with respect to time?
Before speculating what you mean by "Both the time and acceleration arrays are functions.", you should give us an example.
Apologies for the confusion. Time is defined as timeFP1 = FPData1(:,3); which is reading the csv file of Force data 1 and getting the time column. Acceleration is defined as accel1 = (GRF1 / totalMass_kg) - gravity; which is being calculated as Force / Mass - gravity constant. Hope this helps
When I say "data sets" and "functions" I mean variables and function handles.
Integrating data:
x = 1:10;
y = x.^2;
integrateDataSet1 = trapz(x, y)
integrateDataSet1 = 334.5000
integrateDataSet2 = cumtrapz(x, y)
integrateDataSet2 = 1x10
0 2.5000 9.0000 21.5000 42.0000 72.5000 115.0000 171.5000 244.0000 334.5000
Integrating functions:
f = @(x) x.^2;
integrateFunction = integral(f, 1, 10)
integrateFunction = 333
Thank you for the help

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

질문:

2024년 3월 26일

댓글:

2024년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by