MATLAB: The contour plot is empty

contourempty plot

This is my code. I do not have any idea where I made a mistake.
clear
qr=[];
format long
for lam = .3:.2:.7
for c = 2:20
pa=zeros(0, c-1);
for k = 0:c-1
pa(k+1) = lam ^ k / prod(1 : k) * exp(-lam);
end
ap = pa(2 : c); ap(1) = ap(1) + pa(1) - 1;
for i = 1:c -1
a=zeros(1,c-1);
for j = 1:c-1
if j>i, a(i,j) =0; else a(i,j) = pa(i-j+1); end
if i-j == 1, a(i,j) = a(i,j) -1; end
end
end
a = [ones(1,c);[ap',a]]; b=eye(1,c); q=a/b;
L1(c) = 1+(exp(-lam).*q(1)-1)./lam;
end
qr= [qr,L1'];
end
contour(2:c,qr(c:2,:),[.01 .001 .0001 .00001],[.3:.02:.9],[2:c]),grid

Best Answer

The only documented version of contour that can take 5 numeric arguments is the syntax
contour(ax, X, Y, Z, v )
So you need to recheck your inputs.
Meanwhile, after your for c = 2:20 loops, c is going to be left at 20. That would make c:2 an empty matrix, but you use qr(c:2,:) effectively ignoring qr
Your Z needs to be a matrix, but the only matrix you have in your contour call is qr(c:2,:) . If we suppose it should be qr(2:end,:) as the Z then we should look at the minimum and maximum values, and that part of qr ranges from about 0.136 to 0.281. None of your other parameters are in that range, so if one of your other parameters is intended as the v array, none of them would be able to select any data within qr(2:end,:)
I think you need to rethink...
Related Question