It could be put in a loop if you can explain what is the pattern for those index and shiftTime values, such as 1500, 3000, 6000, 9000, 9500, 0.2, 0.3, 0.1.
If there is no pattern, then your code looks good. There might be different approach, but not that different. One option:
ind=[1,1500,0.2;
3000,6000,0.3;
9000,9500,0.1];
Matrix2=zeros(size(Matrix1));
for k=1:size(ind,1)
Matrix2(ind(k,1):ind(k,2),1)=ind(k,3);
end
Matrix2=Matrix2+Matrix1;
Best Answer