Hello,
I have a function and I want to insert sqra(5,5) that i I will get results of x and counter.
How to put all these results into a empty vector by loop ,so x=[] and counter=[] , because then I will have to create a graph.
Thanks for the helpers :)
function fOut = f(xIn,mIn,sIn)
fOut = (exp(-0.5*((xIn-mIn)/sIn)^2)/(sIn*(2*pi)^0.5));
function xOut = sqra(mIn,sIn)
format short
epsilon = 1e-4;
flag = 0;
counter = 0;
x=0.5 ;
while flag == 0
counter = counter + 1
if counter > 10000
error('Too many iterations');
end
x=x+(x-mIn)/((sIn)^2)
if abs((exp(-0.5*((x-mIn)/sIn)^2)/((sIn)*sqrt(2*pi)))) < epsilon
flag = 1;
end
end
xOut = x;
0 Comments
Sign in to comment.