Error using dot A and B must be same size in MATLAB (moment Vectors)

조회 수: 13 (최근 30일)
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"

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 8월 15일
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
SALEH ALHUMAID
SALEH ALHUMAID 2023년 8월 16일
I really appreciate your help, thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by