Calculating integral in MATLAB
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Syed Izhar Ul Haq
le 23 Mar 2021
Commenté : David Hill
le 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 commentaires
Réponse acceptée
David Hill
le 23 Mar 2021
Modifié(e) : David Hill
le 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 commentaires
Syed Izhar Ul Haq
le 24 Mar 2021
Modifié(e) : Syed Izhar Ul Haq
le 24 Mar 2021
David Hill
le 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)));
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!