MATLAB: How to link all nonlinear points (Plot) from (0,0) to (1,1)

connectingloopMATLABplottingroc

The code is look like
for k=1:40 (k only forloop for the number of iterations & must be used)
some operations
sp= output values in between 0 and 1
sn= output values in between 0 and 1
plot (sn,sp);
axis([0 1 0 1]);
hold on
end
hold off;
The outpot is looked like, I want to draw the curve from 0,0 to 1,1 through all points(in between averaging)

Best Answer

You have already asked this question. Check the below code. Note that, I have picked random values between 0 and 1 for sn and sp. In your case, you will evaluate them.
N = 20 ;
val = linspace(0,1,N) ;
sp = zeros(40,1) ;
sn = zeros(40,1) ;
figure
hold on
for k=1:40
sp(k) = randsample(val,1) ;
sn(k) = randsample(val,1) ;
plot (sn(k),sp(k),'.');
end
plot(sn,sp)
Related Question