I have these 3 functions
function r = RingRead(n,p)
r=( p * RingReadggg(n-1,p))+( (1-p)* RingReadggb(n-1,p));
end
function r = RingReadggb(n , p)
if n <= 1
r = 0;
else
r = ((1-p)* RingReadggb(n-1,p) )+ p^2 +( p(1-p)* RingReadggb(n-2,p));
end
end
function r = RingReadggg(n , p)
if n == 1
r = p;
else
r = (p+p(1-p)+( (1-p)^2 * RingReadggb(n-2,p)));
end
end
Below given program uses above given functions.
for p = 0.50:0.05:1
r = RingRead(4,p);
plot(p,r)
hold on
end
When i run this it gives error
??? Subscript indices must either be real positive integers or logicals.
Error in ==> RingRead>RingReadggg at 18 r = (p+p(1-p)+( (1-p)^2 * RingReadggb(n-2,p)));
Error in ==> RingRead at 3 r=( p * RingReadggg(n-1,p))+( (1-p)* RingReadggb(n-1,p));
Error in ==> RingAvailability at 2 r = RingRead(4,p);