Hello I am new to Matlab and I am stuck in doing some maths(dot product) problem today. Please help me out.
I can write the correct code and format in python format, but i got some issues in the matlab. The python code is the following —
% This is the python code
RIMatrix_sph1 = RIMatrix_sph + mass_sph * (np.dot(q1.T, q1) * np.eye(3) - np.dot(q1, q1.T))
The error I encounter in matlab is in this specific part of the code —
(np.dot(q1.T, q1) * np.eye(3) - np.dot(q1, q1.T))
Here is the code I wrote in the Matlab
% This is the MATLAB code
mass_sph = 23.4572;RIMatrix_sph = [0.0938 0 0; 0 0.0938 0; 0 0 0.0938]RIMatrix_sph1 = RIMatrix_sph + mass_sph * (dot(transpose(q1),q1) * eye(3) - dot(q1,transpose(q1)))
I would be appreciated if you coulde help me with the problem.
PS.
This is the correct answer return by my python code —
RIMatrix_sph1 = [1.0321 0 0; 0 1.0321 0; 0 0 0.0938]
This is the wrong answer return by my MATLAB code —
RIMatrix_sph1 = [0.0938 -0.938 -0.9382; -0.9382 0.0938 -0.9382; -0.9382 -0.9382 0.0938]
Thank you Again!
Best Answer