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

1 回表示 (過去 30 日間)
Sultan Mehmood
Sultan Mehmood 2019 年 6 月 13 日
編集済み: madhan ravi 2019 年 6 月 14 日
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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by