Error message "the number of elements in B and I must be the same"

2 次查看(过去 30 天)
Hello all,
In my RUN.m script, I call the function ode23s inside of a parfor loop where steady_state_ode is a separate script .m file. Whenever I run this code, I receive the error message that "Error using steady_state_ode (line 33) In an assignment A(I) = B, the number of elements in B and I must be the same." RUN.m
Ast = [1:4];
parpool(4)
parfor j = 1:4
Y0 = zeros(9,1);
eta = 7;
Y0(4:4)=5; % BemGEFc
Y0(6:6)=Ast(j:j); % Cdc42c
onesN = ones(9);
[T,Y]=ode23s('steady_state_ode',[0 10000],Y0);
RT = Y(end,1)*onesN;
RT(N/2,N/4) = 50; %%spike peak (default N/2,N/4)=500
% RT((N-N/10),(N-N/5))=250; %%second spike peak
M = Y(end,2)*onesN;
Em = Y(end,3)*onesN;
Ec = Y(end,4)*onesN;
RD = Y(end,5)*onesN;
RDIc = (Y(end,6) - (RT(N/2,N/4)*eta/N/N))*onesN;
Ms = Y(end,7)*onesN;
Ems = Y(end,8)*onesN;
Ecs = Y(end,9)*onesN;
end
delete(gcp);
steady_state_ode.m (first few lines)
global k2as
global k2b
global k3
global k3s
global k4a
global k4b
global k5a
global k5b
global k7
global eta
global k8m
global k8n
global k8h
global k9m
global k9n
global k9h
%%equations
Mt = y(2)+y(7);
k8 = k8m*( Mt.^k8n).*(((k8h.^k8n)+( Mt.^k8n)).^(-1));
k9 = k9m*(y(9).^k9n).*(((k9h.^k9n)+(y(9).^k9n)).^(-1));
dy = zeros(9,1);
% RT
dy(1:1) = ((k2a*y(3:3) +k3*y(2:2) ).*y(5:5) - k2b*y(1:1) - k4a*y(3:3).*y(1:1) + k4b*y(2:2) - k7*y(4:4).*y(1:1)) ...
+((k2as*y(8:8) +k3s*y(7:7) ).*y(5:5) - k4a*y(8:8).*y(1:1) + k4b*y(7:7) - k7*y(9:9).*y(1:1));
I tried setting multiple breakpoint both in steady_steate_ode.m and in the parfor loop but the breakpoints in steady_state_ode are never reached and code execution in the RUN.m file stops with out of these errors before any code is executed in steady_state_ode.m. Matlab does not let me set breakpoints inside of the parfor loop. I am unsure about where this issue stems.
  1 个评论
Stephen23
Stephen23 2015-9-2
编辑:Stephen23 2015-9-2
You should not call your script run, because this is the name of very commonly used MATLAB function run.
For the same reason you should never call any function/script/variable length, size, i, j, cd, etc, etc.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2015-9-2
Your global variables are all empty, and empty times anything is empty, and empty plus anything is empty. Your entire expression comes out empty, which cannot be stored in a location that is required to be 1 location wide.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by