필터 지우기
필터 지우기

Find mean of steps in broken signal

조회 수: 1 (최근 30일)
Konvictus177
Konvictus177 2023년 8월 14일
댓글: Star Strider 2023년 8월 16일
Hi,
I have a partially broken signal with NaNs and 5 steps as indicated below.
How can I find the mean level of each of the 5 steps?
The signal is attached.
The signal looks like the following:
Thanks.

채택된 답변

Star Strider
Star Strider 2023년 8월 14일
One approach —
LD = load('y.mat');
y = LD.y;
x = 0:numel(y)-1;
Lv = islocalmax(y>25, 'FlatSelection','all');
start = strfind(Lv, [0 1]);
stop = strfind(Lv, [1 0]);
for k = 1:numel(start)
ymean(k,:) = mean(y(start(k) : stop(k)), 'omitnan');
xmean(k,:) = mean(x(start(k) : stop(k)), 'omitnan');
end
Flat_Means = table(xmean, ymean, 'VariableNames',{'X Centre','Y Mean'})
Flat_Means = 9×2 table
X Centre Y Mean ________ ______ 1618 28.811 1651 30.648 1691 26.499 1725 28.549 1789 35.506 1828 33.727 1841 33.103 1876 33.305 1939 39.992
figure
plot(x, y)
hold on
plot(x(Lv), y(Lv), '.r')
hold off
grid
ylim([min(ylim) 70])
text(xmean, ymean, compose('\\mu = %.2f \\rightarrow',ymean), 'Horiz','right', 'Vert','middle', 'Rotation',-80)
.
  댓글 수: 4
Konvictus177
Konvictus177 2023년 8월 16일
@Star Strider The updated code works perfect! Thank you very much!
Star Strider
Star Strider 2023년 8월 16일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by