Error using dot A and B must be same size in MATLAB (moment Vectors)
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SALEH ALHUMAID
le 15 Août 2023
Commenté : Dyuman Joshi
le 17 Août 2023
Hi
I am reading a scientific paper and trying to reproduce their work. The following are the equations I am working with



solving for this equation

here is my code
syms u_A1 u_A2 u_A3 u_A4 M_A V_A M_B V_B alpha B_r u_0 mu_0 r d pi r11 r12 r13 r14 r21 r22 r23 r24 e_x e_y
mu_a1 = -M_A*V_A;
mu_a2 = -M_A*V_A;
mu_a3 = -M_A*V_A
mu_a4 = -M_A*V_A
mu_A=[mu_a1 mu_a2 mu_a3 mu_a4];
e_x= 1;
e_y=1;
Vector= [e_x ; e_y];
B1=[M_B*V_B*cos(alpha) M_B*V_B*sin(alpha)];
B2=[-M_B*V_B*sin(alpha) M_B*V_B*cos(alpha)];
B3=[-M_B*V_B*cos(alpha) -M_B*V_B*sin(alpha)];
B4=[M_B*V_B*sin(alpha) -M_B*V_B*cos(alpha)];
mu_B1= B1*Vector;
mu_B2= B2*Vector;
mu_B3= B3*Vector;
mu_B4= B4*Vector;
mu_B=[mu_B1;mu_B2;mu_B3;mu_B4];
r11= [r-r*cos(alpha)+d -r*sin(alpha)]*Vector;
r21= [(-r*cos(alpha)) -(r+r*sin(alpha)+d)]*Vector;
r31= [-(r+r*cos(alpha)+d) -(r*sin(alpha))]*Vector;
r41= [(-r*cos(alpha)) (r-r*sin(alpha)+d)]*Vector;
r12= [(r-r*sin(alpha)+d) r*cos(alpha)]*Vector;
r22= [-(r*sin(alpha)) -(r-r*cos(alpha)+d)]*Vector;
r32= [-(r+r*sin(alpha)+d) r*cos(alpha)]*Vector;
r42= [-(r*sin(alpha)) (r+r*cos(alpha)+d)]*Vector;
r13= [r+r*cos(alpha)+d r*sin(alpha)]*Vector;
r23= [r*cos(alpha) -(r-r*sin(alpha)+d)]*Vector;
r33= [-(r-r*cos(alpha)+d) r*sin(alpha)]*Vector;
r43= [r*cos(alpha) (r+r*sin(alpha)+d)]*Vector;
r14= [(r+r*sin(alpha)+d) -r*cos(alpha)]*Vector;
r24= [r*sin(alpha) -(r+r*cos(alpha)+d)]*Vector;
r34= [-(r-r*sin(alpha)+d) -r*cos(alpha)]*Vector;
r44= [r*sin(alpha) (r-r*cos(alpha)+d)]*Vector;
r=[r11 r21 r31 r41; r12 r22 r32 r42; r13 r23 r33 r43; r14 r24 r34 r44];
dotA= dot(r,mu_A);
I am getting this error "Error using dot A and B must be same size"
0 commentaires
Réponse acceptée
Dyuman Joshi
le 15 Août 2023
You are not exactly doing what's done in the reference.
s = size(r);
B = zeros(s,'sym');
for m=1:s(1)
for n=1:s(2)
B(m,n) = dot(mu_A(m),r(m,n))/norm(r(m,n),2)^3;
end
end
%B = -mu_not*B/(4*pi)
4 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!