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 Center および File Exchange で Address Missing Coverage についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!