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