how to return to a back step by checking back steps . problem in 4 and 5 step

1 次查看(过去 30 天)
step 2:
x=0.3;
x=0.3;
p=0.343;
for n=2:65536;
if x(n-1)>=0 & x(n-1)<=p
x(n)=x(n-1)/p;
else
x(n)=(1-x(n-1))/(1-p);
end
end
step 3:
K(n)= mod(floor((x(n)*10^2-floor(x(n)*10^2))*10^3);,256);
if K(n)<3
K(n)=K(n)+3;
end
step 4. Checking ?(n), if ?(n) < 3, then ?(n) = ?(n) + 3.
Step 5. Let n ← n+ 1, return to Step 3 until n reaches ?.

采纳的回答

Raj
Raj 2019-6-14
After running the code upto here:
x=0.3;
x=0.3;
p=0.343;
for n=2:65536;
if x(n-1)>=0 & x(n-1)<=p
x(n)=x(n-1)/p;
else
x(n)=(1-x(n-1))/(1-p);
end
end
You get x as an 1x65536 matrix. Then you have to calculate K like this:
for ii=1:numel(x)
K(ii)= mod(floor((x(ii)*10^2-floor(x(ii)*10^2))*10^3),256);
end
Then you have to check for each element of K w.r.t to the condition like this:
for ii=1:numel(K) % I assume L is total number of elements in K
if K(ii)<3
K(ii)=K(ii)+3;
end
end
I am not sure but is this what you are looking for? Where is the problem?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by