I need to reproduce the paper result

1 回表示 (過去 30 日間)
Ted Erdenekhuyag
Ted Erdenekhuyag 2022 年 12 月 2 日
回答済み: Fifteen12 2022 年 12 月 2 日
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 Center および File ExchangeMathematics and Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by