I need to reproduce the paper result

1 次查看(过去 30 天)
when i apply m=4 delay timer consecutive samples less than 4 should be eliminated how to do that on matlab x(t) is actually random variable only takes 1(when alarm raises) 0 (when alarm clears)
this is what on the the paper
syms i;
t = 3:50;
for t=3:50
x(t)=rand(1,1)<=0.5;
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(t,x(t))
xlabel('t')
ylabel('x(t)') this is the code i have trying to write but not complete

回答(1 个)

Fifteen12
Fifteen12 2022-12-2
I'm not sure what the difference between x_a and x_a,m is, but maybe this would work:
x = [1, 1, 1, 1, 1, 0];
m = 4;
t = 6;
sum_x = sum(x(max(0,t-m+1):t));
if sum_x == m && x(t-1) == 0
x(t) = 1;
elseif sum_x == m && x(t-1) == 1
x(t) = 0;
else
x(t) = x(t-1);
end
disp(x(t))
1
this assumes that x_a and x_a,m are the same list

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by