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.

2 次查看(过去 30 天)
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
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.
  1 个评论
Rik
Rik 2022-5-11
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
This page is now archived on the Wayback Machine.

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2022-5-9
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.
  14 个评论
Maddy
Maddy 2022-9-25
what should have to do with this issue?
left side is scalar and right side is vector. and becuase of this error coming.
how can i convert vectro into scalar?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by