**Can not figure out my ??? Subscripted assignment dimension mismatch-problem**

EDIT: This is Matlab code.

Hello!

I have some matlab code and I've run into a problem that I can't seem to be able to solve. I hope that someone might help me find a solution. Here is the error

Code:

```
??? Subscripted assignment dimension mismatch.
Error in ==> simrun at 30
[agenda(:,i) in out inagenda
outagenda]=agendafunc(eventlist,tokendistr(:,i),i,inlist,outlist);
Error in ==> main at 5
simrun();
```

Code:

```
(...)
for i=1:T
[agenda(:,i) in out inagenda outagenda]=agendafunc(eventlist,tokendistr(:,i),i,inlist,outlist);
(...)
end
(...)
```

The agendafunc() function is this:

Code:

```
function[agendatoday in out inagenda outagenda]=agendafunc(eventlist,tokenstoday,dayno,inlist,outlist)
global tokentreshold popsize p3
agendatoday=zeros(popsize,1);
in=0;out=0;
inagenda=zeros(popsize,1);
outagenda=zeros(popsize,1);
for i=1:popsize
%comments
if(tokenstoday(i)>tokentreshold)
if(eventlist(i,dayno)==1)
agendatoday(i)=1; % comments
out=out+1;
outagenda(i)=out;
else if(eventlist(i,dayno)==2 || eventlist(i,dayno)==0)
agendatoday(i,dayno)=0; % comments
else
agendatoday(i,dayno)=0; % comments
end
end
else if(tokenstoday(i)==0)
%comments
if(eventlist(i,dayno)==2)
agendatoday(i)=2;
in=in+1;
inagenda(i)=in;
else
a=rand;
if(p3<a)
agendatoday(i)=2; % comments
%comments
in=in+1;
inagenda(i)=in;
end
end
else if(check(tokenstoday,outlist,inlist,dayno)==true)
%comments
if(eventlist(i,dayno)==2)
agendatoday(i)=2;
in=in+1;
inagenda=in;
else if(eventlist(i,dayno)==1)
agendatoday(i)=1;
out=out+1;
outagenda(i)=out;
else if(eventlist(i,dayno==0))
a=rand;
if(p3<a)
agendatoday(i)=2; % comments,
%comments
in=in+1;
inagenda(i)=in;
end
end
end
end
else
%comments
if(eventlist(i,dayno)==1)
agendatoday(i)=1;
out=out+1;
outagenda(i)=out;
else if(eventlist(i,dayno)==2)
agendatoday(i)=2;
in=in+1;
inagenda(i)=in;
else
agendatoday=0;
end
end
end
end
end
end
end
```

I have no idea what went wrong, as the array sizes I believe to be of correct size. The error takes place the second run of the loop, i.e. i=2 in the first for loop in the middle code window of this page. Does anyone have a tip for me what I could be missing or why Matlab finds an error?

Thanks a lot.

Last edited: