How can I use this code if max = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27] instad of max = 27.
Some one can please help me with this code thank you..
clear allclose allclcmax =27;%max=[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27]; I want to use this instead of max= 27 for same code
k=0;s=0;c=0;flag=1;state(1)=0;% initialinput=0
% tempin=initialinput
% input= randi([0 1],1,max)
input=[ 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0]; initialinput=input(1);output=input;for i=1:max if(i==1) if(input(i)==initialinput) state(i)=state(1); seq(i)=s;% s=s+1;
if(flag>1 && flag <= 9) number=k; integ=floor(number); k=integ; k=k+(2^(flag))/1000; t(i)=k; flag=flag+1; else k=k+1; t(i)=k; end end elseif(input(i)==input(i-1)) state(i)=state(i-1); s=s+1; seq(i)=s; if(flag>1 && flag <= 9) number=k; integ=floor(number); k=integ;% fract=number-integ;
k=k+(2^(flag))/1000; t(i)=k; flag=flag+1; else k=k+1; t(i)=k; end elseif(input(i)~=input(i-1)) state(i)=state(i-1)+1; seq(i)=0; s=0; if(c==0) flag=1; end number=k; integ=floor(number); k=integ; k=k+1; t(i)=k; c=0;%
flag=flag+1; end end
Best Answer