Calculating integral in MATLAB
5 views (last 30 days)
Show older comments
Syed Izhar Ul Haq
on 23 Mar 2021
Commented: David Hill
on 24 Mar 2021
how can I calculate the integral as shown in the screen shot. where j1 is of 1x3 matrix and j2 is also 1x3 matrix. while g1 is 300x3 matrix and also g2 is 300x3 matrix.
in the screen shot the '.' represents the dot product. your suggestion and help would be highly appreciated

0 Comments
Accepted Answer
David Hill
on 23 Mar 2021
Edited: David Hill
on 23 Mar 2021
I am assuming each row of g1 and g2 is going from T=0 to t; otherwise you will have to describe the functions g1 and g2 and how they relate to T (since the integration is with respect to it). I assume you can treat the integration as a summation.
dT=t/300;%not sure what t is and I assume the change is consistent point to point
AlphaGyr=dT*(dot(g1,repmat(j1,300,1))-dot(g2,repat(j2,300,1)));%dot is just sum(g1.*repmat(j1,300,1))
2 Comments
David Hill
on 24 Mar 2021
The dot product of a matrix does the sumation automatically so you don't need a loop. You just need to create same size matrix out of j1 and j2 as g2 and g2 using repmat. Below should work. Yes the final answer will be 1x300.
dT=100;
AlphaGyr=dT*(dot(g1,repmat(j1,300,1))-dot(g2,repat(j2,300,1)));
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!