MATLAB: Replacing the for loops

replace for loops

L=(length(time)-1);
for q=1:numPT
for h=1:L
x(q,h)=SortDate(q,5);
y(q,h)=SortDate(q,6);
c(q,h)=SortDate(q,4);
end
end

Best Answer

cxy = permute(repmat(SortDate(q,4:6),1,1,L),[1 3 2]);
here cxy your arrays c,x and y as cxy = cat(3,c,x,y)