Error using dot A and B must be same size in MATLAB (moment Vectors)
    3 views (last 30 days)
  
       Show older comments
    
    SALEH ALHUMAID
 on 15 Aug 2023
  
    
    
    
    
    Commented: Dyuman Joshi
      
      
 on 17 Aug 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 Comments
Accepted Answer
  Dyuman Joshi
      
      
 on 15 Aug 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 Comments
More Answers (0)
See Also
Categories
				Find more on Image Data Workflows in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
