MATLAB: Attempted to access (5,0); index must be a positive integer or logical

please help

Dear all, when I tried to plot the T vs. s diagram, the error "Attempted to access (5,0); index must be a positive integer or logical." shows up. When I switch T=0:1:30 to T=1:1:30, the diagram is very wrong. The good diagram only comes when I set t = 1:length(T). Could someone tells me why? Thanks a lot.
clear all;
Sigma = 5:5:30;
T = 0:1:30;
for sigma = Sigma;
for t = T;
s(sigma,t) = (sigma-3+0.072*t*(1+0.072*t))/0.77;
end;
end;
plot(s,T);

Best Answer

  • Is it better if you do this instead?
    s(sigma,t+1) = (sigma-3+0.072*t*(1+0.072*t))/0.77;
    Notice that I shifted your index, so that you start at 1 instead of 0.