# Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-2000.

6 views (last 30 days)

Show older comments

Please help me solve this issue.

clc

close all;

clear all;

b01 = 0.011 ; % Density of 1state/1time

b02 = 0.001; % Density of 2state/1time

t = 2000; % Number of time steps

s = 100; % Number of states

b01(t) = b01 + gamma(t);

b02(t) = b02 + gamma(t); % State changing depend on time

b = b01 + b02; % Density of state changing

t/dis;

for j = 1 : s

L(j) = j-1;

end

% Determination of startvector

p = zeros(s,1);

p(1) = 0;

p(2) = 0.0006;

p(3) = 0.0024;

p(4) = 0.0079;

p(5) = 0.0224;

p(6) = 0.0540;

p(7) = 0.1109;

p(8) = 0.1942;

p(9) = 0.2897;

p(10) = 0.3683;

p(11) = 0.3989;

p(12) = 0.3683;

p(13) = 0.2897;

p(14) = 0.1942;

p(15) = 0.1109;

p(16) = 0.0540;

p(17) = 0.0224;

p(18) = 0.0079;

p(19) = 0.0024;

p(20) = 0.0006;

p(21) = 0;

% Determination of Markov matrix

R = zeros(s,s);

for i = 1 : s-2

R(i,i) = 1-b;

R(i+1,i) = b01;

R(i+2,i) = b02;

end

##### 1 Comment

Rik
on 11 May 2022

### Accepted Answer

Torsten
on 9 May 2022

Setting

b01(t) = b01 + gamma(t);

b02(t) = b02 + gamma(t);

b = b01 + b02;

makes b01, b02 and b to arrays of size 1x2000 since t = 2000.

So the assignments

R(i,i) = 1-b;

R(i+1,i) = b01;

R(i+2,i) = b02;

don't work.

One remark: Don't name arrays min or max - these are internal MATLAB functions.

### More Answers (0)

### See Also

### Community Treasure Hunt

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

Start Hunting!