Same code in a loop but different plots
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!