フィルターのクリア

Same code in a loop but different plots

1 回表示 (過去 30 日間)
Youngmin
Youngmin 2022 年 11 月 4 日
コメント済み: Youngmin 2022 年 11 月 4 日
Hello world,
I am working on making plots to visualize my data, but I am not sure what is wrong with my code. I tried to draw four subplots to display when each muscle was activated by filling the color on the area between the threshold and EMG signals. Even though I used for loop, the first column data keep displaying different patterns of filling and increasing threshold. I have attached sample data and code below.
I would really appreciate any help to find out how to fix this issue.
clear;
clc;
close all;
load sample.mat;
thr = [0.0057 0.0401 0.0090 0.0216];
t = (0:length(sample)-1)/2000;
for i = 1:4;
subplot(4,1,i);
plot(t,movmean(sample(:,i),100));
hold on;
fill(t,max(movmean(sample(:,i),100),thr(i)), ...
thr(i),"LineStyle","none");
xlim([0, t(end)]);
end
  2 件のコメント
KSSV
KSSV 2022 年 11 月 4 日
I think code works fine. What you are expecting?
Youngmin
Youngmin 2022 年 11 月 4 日
What I am expecting is that all four subplots look similar to each other. However, the threshold of the first plot keeps increasing unlike other subplots despite a single value and the filling area keeps reversing to over or to under the threshold. I have attached the screenshot of the plot (created by the code above) for a better understanding. Interestingly, this issue is gone when I use the area function, but I would like to use fill because the area does not allow "LineStyle - none'. Do you have any suggestions?

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2022 年 11 月 4 日
area also supports linestyle, none.
load('sample.mat')
thr = [0.0057 0.0401 0.0090 0.0216];
t = (0:length(sample)-1)/2000;
for i = 1:4
subplot(4,1,i);
plot(t,movmean(sample(:,i),100));
hold on;
area(t,max(movmean(sample(:,i),100),thr(i)), ...
thr(i),'LineStyle','none');
xlim([0, t(end)]);
end
  1 件のコメント
Youngmin
Youngmin 2022 年 11 月 4 日
@KSSV Thank you for your suggestion. I would like to remove the line of threshold when the signals are not exceeding the threshold as you can see in the second plot (red solid lines are across the plot despite LineStyle, none). Is there any way to remove that line and keep the filled area only when the signal exceeds the threshold?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by