Hello all please help me to plot this function
    5 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    

number=0;
m=4
for t=1:50
    x(i,1)=rand(1,1)<=0.5
    if symsum(x(i,1),i,t-m+1,t)=m&&x(t-1)=0
         x(t,1)= 1
    else
       symsum(x(i,1),i,t-m+1,t)=0&&x(t-1)=1
       x(t,1)= 0
    end
end 
figure,stem(1:50,x)
xlabel('t')
ylabel('x(t)')
2 Kommentare
  David Hill
      
      
 am 2 Dez. 2022
				You need to define the past. When t=1 your are looking back to x(-2),x(-1),and x(0). These initial values need to be defined.
Antworten (1)
  VBBV
      
      
 am 2 Dez. 2022
        
      Bearbeitet: VBBV
      
      
 am 2 Dez. 2022
  
      The conditions seem wierd, considering random number series .as inputs
m=4
syms i;
% t = 50;
for t=2:50
    x(t)=randi([0 4],1);
    if double(symsum(x,i,t-m+1,t))== m & x(t-1)==0
         x(t)= 1;
    elseif  double(symsum(x,i,t-m+1,t))==0 & x(t-1)==1
         x(t)= 0;
    end
end 
figure,stem(1:50,x)
xlabel('t')
ylabel('x(t)')
2 Kommentare
Siehe auch
Kategorien
				Mehr zu Linear Algebra finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


