Unable to perform assignment because the left and right sides have a different number of elements

1 次查看(过去 30 天)
So, i was testing some filters, when I recieved the error in the title. After some fiddling, I arrived to conclusion that i must be making a mistake by using r and dm variables as vectors. Or I am missing something?
% Constants
r = [0, 0, 0.078, 0.079, 0.079, 0.079];
s = 2;
dm = [0, 1, 1, 1, 3, 9];
% Initialize vectors
N = 300;
x1 = zeros(N, 1);
x2 = zeros(N, 1);
% Initial conditions
x1(1) = 1001;
x2(1) = 50;
% Simulate deterministic discrete-time dynamical system
for k = 1:N
x1(k+1) = (1+r)*x1(k) - s*x2(k);
if x1(k) > 1000
x2(k+1) = x2(k) + dm;
else
x2(k+1) = x2(k) - dm;
end
% Restrict to [0, 100]
x2(k+1) = max(0, min(x2(k+1), 100));
end
% Adding the stability testing
if x1(N) < 0
disp ("bancrupt")
elseif x1(N) > 2*x1(1)
disp ("rich")
else
disp ("stable")
end
  5 个评论

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Address Missing Coverage 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by