Hi all,
I am trying to run a big loop, and it runs the first time around but then the second time it gives the error. "Unable to perform assignment because the left and right sides have a different number of elements". I just do not understand why it is giving this error as I indexed it a way it just should overide the previous value as the values I need are stored later on in the loop. Can anyone see why this error might be occuring and what I can do about it?
I know the error is happening at this line of code:
for j=1:length(V1starttime) rtimesep3(j)=min(abs(V1starttime(j)-CCstarttime3)); % Calculating the testsatistics of CC --> % should show the time seperation of each HFW and the closest CC
end
This is the full loop which I eventually need to run 10.000:
%do 10.000 randomizations
CCstarttime3=zeros(1,1265);% create vector to store CCstarttime3 in --> last number of the vector based on V3on
SSstarttime2=zeros(1,1);Mrtimesep2=zeros(1,10000);Mrtimesep3=zeros(1,10000);rtimesep2=zeros(62,1);rtimesep3=zeros(62,1);counter=1i=1j=1for i=1:10fprintf('Itteration#%d\n',counter);counter=counter+1;SSshift2=round(rand(1,1)*2250); %random shift time
SSstarttime2(i,:)=V2starttime+SSshift2; % adds the randomshift time to the starttimes of SS
toobig2=find(SSstarttime2>2250); % finds the SS starttimes that went outside the timeframe
SSstarttime2(toobig2)=SSstarttime2(toobig2)-2250; % subtracts the timeframe from toobig 2
CCshift3=round(rand(1,1)*2250); %random shift timeCCstarttime3(i,:)=V3starttime+CCshift3; % adds the randomshift time to the starttimes of CC
toobig3=find(CCstarttime3>2250); % finds the CC starttimes that went outside the timeframe
CCstarttime3(toobig3)=CCstarttime3(toobig3)-2250; % subtracts the timeframe from toobig 3
for j=1:length(V1starttime) rtimesep3(j)=min(abs(V1starttime(j)-CCstarttime3)); % Calculating the testsatistics of CC --> % should show the time seperation of each HFW and the closest CC
endfor l=1:length(V1starttime) rtimesep2(l)=min(abs(V1starttime(l)-SSstarttime2)); % Calculating the testsatistics of CC --> % should show the time seperation of each HFW and the closest CC endMrtimesep2(i,:)=mean(rtimesep2); % Calculating the mean of the teststatistics of SS
Mrtimesep3(i,:)=mean(rtimesep3); % Calculating the mean of the teststatistics of CC
end
Cheers,
Simone
Best Answer