MATLAB: Error using .^ Matrix dimensions must agree.

simulink

>> rotor_angle.data
ans =
0
-198.3198
-305.6161
-272.6427
-114.5335
96.1435
262.6932
308.6737
212.9811
19.5358
-182.8759
-301.3524
-281.5161
-132.4714
77.3741
251.7070
310.5130
226.8018
38.9946
-166.7102
-295.8993
-289.2786
-149.8866
58.2994
239.7275
311.1270
239.7275
58.2994
-149.8866
-289.2786
-295.8993
-166.7102
38.9946
226.8018
310.5130
251.7070
77.3741
-132.4714
-281.5161
-301.3524
-182.8759
19.5358
212.9811
308.6737
262.6932
96.1435
-114.5335
-272.6427
-305.6161
-198.3198
0.0000
>> k=1:51;
>> L=sum(log(abs(rotor_angle.data(k).^(-123*k))))
Error using .^
Matrix dimensions must agree.
Each element of the array %rotor_angle% must be raised to a power and added. In each case, the degree is the ordinal number of the array element
My matlab version R2016a.

Best Answer

This is because rotor_angle is 51x1 and k is 1x51. Transpose one of them.
L=sum(log(abs(rotor_angle.data(k).^(-123*k'))))
Related Question