implementation of iterative function
显示 更早的评论
How can we implement the iterative function F(x)= [((1-2*q)*(x-q))/(p-q)]+q we have to iterate it for some values of i and generate the values of xi where xi=F(xi-1). initially let.
采纳的回答
n=...;
p=...;
q=...;
x0=...;
f=@(x)(1-2*q)*(x-q)/(p-q)+q;
for ii=1:n
xnew=f(xold);
xold=xnew;
end
Best wishes
Torsten.
8 个评论
here xold=x0??? and we have to store all the values of xnew into a vector.
with the help of this getting inf value of x in each iteration.
ok, replace
x0=...;
by
xold=...;
And don't use p=q -:)
Best wishes
Torsten.
not using p=q still getting inf values. Im=imread(); [n m]=size(A); L=m*n; AVector = A(:); P=A; x0=0.27;p=0.4;q=0.1; xold=x0; f=@(x)(1-2*q)*(x-q)/(p-q)+q; for i=1:n; xnew=f(xold); xold=xnew; end for j = 1:numel(P) i = P(j); output(j) =xold end
@shivani: please learn to format your code correctly to make it readable: use the {} Code button that is above the textbox. The Preview pane is pretty handy too!
not taking p=q still getting inf values.
Im=imread();
[n m]=size(A);
L=m*n;
AVector = A(:);
P=A;
x0=0.27;p=0.4;q=0.1;
xold=x0;
f=@(x)(1-2*q)*(x-q)/(p-q)+q;
for i=1:n;
xnew=f(xold);
xold=xnew;
end
for xi = 1:numel(P);
i = P(xi);
output(xi) =xold;
end
Im=imread();
[n m]=size(A);
L=m*n;
x0=0.27;
p=0.4;
q=0.1;
xold=x0;
output=zeros(L);
output(1)=xold;
f=@(x)(1-2*q)*(x-q)/(p-q)+q;
for ii=1:L-1
xnew=f(xold);
xold=xnew;
output(ii+1)=xold;
end
Note that xold becomes bigger and bigger during the Iteration such that you may get xold=Infinity if L is large enough.
Best wishes
Torsten.
ok thanx..:)
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Inverse Gaussian Distribution 的更多信息
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
