Matrix dimensions must agree ERROR WITH MY CODE.Can anyone suggest a solution to this problem in my code below

1 次查看(过去 30 天)
x1 = [x_m';zeros(t_o,1)];
x2 = [zeros(t_o,1);x_m';zeros(t_o,1)];
x3 = [zeros(2*t_o,1);x_m';zeros(t_o,1)];
x4 = [zeros(3*t_o,1);x_m';zeros(2*t_o,1)];
x5 = [zeros(4*t_o,1); x_m'];
y_m = x1+x2+x3+x4+x5;% Simulated Measurement
y_m=y_m';

回答(1 个)

Walter Roberson
Walter Roberson 2018-6-25
Suppose the number of rows in x_m' is M. Then x1 has M+t_o rows, x2 has t_o+M+t_o = M+2*t_o rows, x3 has 2*t_o+M+t_o = M+3*t_o rows, x4 has 3*t_o+M+2*t_o = M+5*t_o rows, x5 has 4*t_o+M = M + 4*t_o rows.
And then you try to add these items, each of which has a different number of rows (except in the case where t_o is zero). You cannot add when the number of rows or columns or pages is different.

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by