How do I resolve the error "Matrix dimensions must agree" here?

1 view (last 30 days)
I'm trying to multiply 2 matricies in MatLab, the first is a 13x13 and the second is a 13x4. The inner dimensions of these matricies should agree and yet I am still getting the error "Matrix dimensions must agree". I have pasted the code below just to get some other eyes on it to see if maybe you guys can catch something that I am missing, thank you.
a_mat = [0 3.7699e+02 0 0 0 0 0 0 0 0 0 0 0;
-2.2138e-01 -5.8734e-04 -1.1884e-01 -1.0702e-01 -1.6010e-02 -6.9250e-02 -2.2234e-05 -5.8734e-05 2.2021e-01 -5.8734e-04 4.2564e-02 -1.8689e-04 2.2012e-03;
1.1124e-01 -4.4138e-04 -2.1738e+00 2.3382e+00 -1.1894e-02 -5.1077e-02 -1.6709e-05 1.4555e+00 -1.1212e-01 -4.4138e-04 -2.5957e-03 -1.4015e-04 2.5927e-02;
-3.5075e+00 2.3003e-02 3.0169e+01 -3.4136e+01 3.1049e-02 7.4233e-02 8.7077e-04 2.3003e-03 3.5534e+00 2.3003e-02 -1.4998e-01 7.3064e-03 -1.1509e+00;
-2.4341e-01 -3.4554e-03 -3.0690e-02 -2.8001e-02 -8.4423e+00 6.3190e+00 -1.3080e-04 2.3003e-03 3.5534e+00 2.3003e-02 -1.4998e-01 7.3064e-03 -1.1509e+00;
-2.5771e+00 -3.6583e-02 -3.2492e-01 -2.9646e-01 1.5185e+01 -2.1623e+01 -1.3849e-03 -3.6583e-03 2.5039e+00 -3.6583e-02 1.2545e+00 -1.1629e-02 1.1174e+00;
2.8696e+00 -6.6513e-02 -9.0935e+00 -8.1915e+00 2.5309e+00 1.1307e+01 -1.5244e-01 -6.6513e-03 -3.0025e+00 -6.6513e-02 1.3396e+00 -2.1134e-02 2.6921e+00;
2.2109e+01 -1.0098e+00 -1.5145e+02 -2.0588e+02 4.5756e+01 2.0389e+02 1.4923e+01 -1.3069e+02 -2.4127e+01 -1.0098e+00 2.3010e+01 -3.2087e-01 3.8995e+01;
0 0 0 0 0 0 0 0 0 3.7699e+02 0 0 0;
2.2016e-03 2.7398e-06 9.4525e-04 8.5103e-04 2.1091e-04 9.1859e-04 1.0372e-07 2.7398e-07 -2.1975e-03 -3.3333e-01 1.6015e-04 -2.9255e-05 -2.6203e-04;
0 0 0 0 0 0 0 0 0 0 0 0 1.0000e+00;
-4.8992e-05 9.6388e-07 4.4008e-05 3.9713e-05 -1.8464e-05 -8.3461e-05 0 0 5.2616e-05 9.6388e-07 -2.3268e-05 -3.0392e-02 -3.6324e-05;
-2.8199e+01 8.1414e-01 5.2452e+01 4.7296e+01 -1.6444e+01 -7.4507e+01 3.0819e-02 8.1414e-02 2.9826e+01 8.1414e-01 -1.6107e+02 7.5103e+00 -1.8906e+02]
b_mat=[0 0;
-5.8734e-04 4.2564e-02;
-4.4138e-04 -2.5957e-03;
2.3003e-02 -1.4998e-01;
-3.4554e-03 1.1849e-01;
-3.6583e-02 1.2545e+00;
-6.6513e-02 1.3396e+00;
-1.0098e+00 2.3010e+01;
0 0;
2.7398e-06 1.6015e-04;
0 1.0000e+00;
1.0000e+00 -2.3268e-05;
8.1414e-01 -1.6107e+02]
c_ang=[ 7.7302e-01 -2.4427e-04 2.3391e-01 2.1050e-01 9.4889e-02 4.1784e-01 -9.2469e-06 -2.4427e-05 2.2649e-01 -2.4427e-04 3.4508e-02 -7.7871e-05 -1.0880e-02;
1.3210e-04 0 5.6710e-05 5.1057e-05 1.2656e-05 5.5121e-05 0 0 9.9987e-01 0 9.6111e-06 -1.7549e-06 -1.5718e-05;
5.6135e-01 6.2868e-05 2.0058e-01 1.8053e-01 6.2297e-02 2.7339e-01 2.3799e-06 6.2868e-06 4.3877e-01 6.2868e-05 5.3039e-02 1.9510e-05 -4.0659e-02;
5.6415e-01 -2.6887e-05 1.9536e-01 1.7582e-01 6.3890e-02 2.8078e-01 -1.0178e-06 -2.6887e-06 4.3580e-01 -2.6887e-05 4.0344e-02 -9.0058e-06 -2.6848e-02;
1.3067e-04 0 5.8178e-05 5.2382e-05 1.0840e-05 5.2511e-05 0 0 9.9992e-01 0 7.3228e-06 1.2864e-03 -1.9291e-05]
c_v=[-5.9420e+01 1.5319e+00 1.0999e+02 9.9164e+01 -3.4720e+01 -1.5668e+02 5.7992e-02 1.5319e-01 6.2482e+01 1.5319e+00 -3.3844e+02 4.8650e-01 -3.7722e+02;
-2.4548e-02 4.8296e-04 2.2051e-02 1.9899e-02 -9.2518e-03 -4.1819e-02 1.8283e-05 4.8296e-05 2.6364e-02 4.8296e-04 -1.1659e-02 -1.5228e+01 -1.8200e-02;
5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02 5.0106e+02;
-2.8284e+01 7.2927e-01 5.2368e+01 4.7211e+01 -1.6529e+01 -7.4592e+01 2.7606e-02 7.2927e-02 2.9741e+01 7.2927e-01 -1.6116e+02 7.4833e+00 -1.7962e+02]
C=[c_v(3,:);
c_v(2,:);
c_ang(3,:);
c_ang(2,:)]
C_new=transpose(C)
row_vector=a_mat.*C_new

Answers (1)

Mohamad
Mohamad on 9 Nov 2020
Hi , follow this correction , now you get the row_vector matrix with size ( 13 x 4 )
row_vector=a_mat*C_new ;

Categories

Find more on Loops and Conditional Statements 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!