1) replace (length(A)-1), length(P) and (length(B)-1).
2)make temporary variables lentemp and rtemp
3)add one more index j
4)choose data for plotting
r1=(length(A)-1); r2=length(P); r3=(length(B)-1); %replacing
parfor j=1:r2
for i=1:r1
rtemp=r; %making temporary variables
for k=1:r3
lentemp=len; %making temporary variables
ri(k,l,j)=lentemp(k); %adding index
sr(1,i,j)=rtemp(i); %adding index
end
end
end
plot(ri(:,:,end),sr(:,:,end)); %choosing data