New Reply

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

 
Share Thread
Aug20-12, 03:47 AM   #1
 

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();
And this is the code(omitted parts that I think are less important:)
Code:
(...)
for i=1:T
    [agenda(:,i) in out inagenda outagenda]=agendafunc(eventlist,tokendistr(:,i),i,inlist,outlist);
(...)    
end
(...)
Here agenda is a 150x600 array, T=600, in and out are doubles, inagenda and outagenda are both 150x1 arrays, eventlist is a 150x600 array, tokendistr is a 150x600 array, inlist and outlist are both 150x600 arrays. popsize=150.

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
where I think the most important part is that I never change the size of any array. I also ommitted my comments here.

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.
PhysOrg.com science news on PhysOrg.com

>> New language discovery reveals linguistic insights
>> US official: Solar plane to help ground energy use (Update)
>> Four microphones, computer algorithm enough to produce 3-D model of simple, convex room
New Reply

Similar discussions for: Can not figure out my ??? Subscripted assignment dimension mismatch-problem
Thread Forum Replies
Type mismatch problem FORTRAN 77 Programming & Comp Sci 4
[Mathematica] Trouble understanding subscripted variables Math & Science Software 3
Subscripted Index Differential Geometry 1
[MATLAB] Subscripted assignment dimension mismatch. Math & Science Software 0
Subscripted Variables Precalculus Mathematics Homework 4