
How can I compute Line Integral problem in MATLAB?
28 views (last 30 days)
Show older comments
MathWorks Support Team
on 19 Aug 2021
Answered: MathWorks Support Team
on 19 Aug 2021
Assume the situation where a particle having specific Force Field(vector) moves over a certain curve and you will need to calculate total energy along with the path. This is called as the Line Integral that appears in the area of Mechanics Problem in Physics. Below is the typical equation you may focus:
∫F⋅dr = ∫F(r(t))⋅r′(t)dt
As far as I looked for, there is no equivalent MATLAB functions or workflow demonstrated in existing documents to solve this sort but could you suggest example solutions for this?
Accepted Answer
MathWorks Support Team
on 19 Aug 2021
As you mention, there is no explicitly corresponding functions in MATLAB. However, hope following example program helps solve your own Line Integral problem.
Assume that there is a particle having below Force Field and the particle moves anti-clockwise along with the below circle.
r(t) = [cos(t)+2;sin(t)] % curve
F(x,y) = [−y;x] % force field

MATLAB program:
syms F1(x,y) F2(x,y) r1(t) r2(t)
r1(t) = cos(t)+2;
r2(t) = sin(t);
F1(x,y) = -y;
F2(x,y) = x;
r = [r1;r2];
F = [F1;F2];
Fr = F(r1(t),r2(t));
dr = diff(r(t),t);
integrand = dot(Fr,dr);
work = int(integrand,t,[0,2*pi])
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!