It must be something in your environment. Running the code here in the forum produces no errors. I would suggest clearing the workspace.
CTemp=650; %<-- INPUT temperature in Celcius
KTemp=CTemp+273; %conversion to Kelvin
Bdepth=(CTemp/30)*1000; %<-- INPUT burial depth in meters, related to temperature
R=8.314; %gas constant
%Matrix values
strainrate=[1e-5 1e-7 1e-9 1e-11 1e-13 1e-15]; %range of strain rate values
grainsize=[0.01 0.1 1 10 100 1000]; %range of grain size in microns
% l = length(strainrate);
% stress = zeros(l,l);
cc=hsv(12); %generates a set of colors
%Diffusion Creep - Walker et al., 1990
for i=1:length(strainrate)
for j=1:length(grainsize)
A=10^4.93;
m=-1.87;
Q=190000;
n=1.7;
temp(i,j)=(strainrate(i)/(A*(grainsize(j).^m)*(exp(-Q/(R*KTemp)))))^(1/n);
stress(i,j) =[temp(i,j)];
end
loglog(grainsize, stress(i,:),'color',cc(i,:))
hold on
end