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

2 views (last 30 days)
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';

Answers (1)

Walter Roberson
Walter Roberson on 25 Jun 2018
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.

Categories

Find more on Simulink 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!