I have a code that looks like this:
figure
for ii = 1:12
y =Data.StrideTimeIntervals_15minTrial.PD(:,ii);
subplot (3,4,ii),plot (y, 'r')
title (sprintf('PD %d',ii))
xlabel ('ISI #')
ylabel ('ISI (s)')
axis ([0,500,0.8,1.2])
disp (sprintf('PD %02d Done',ii))
end
How would I plot the outliers in red circles on all 12 graphs on the subplots. Here is what the subplots look like. figure1.PNG

 採用された回答

the cyclist
the cyclist 2019 年 10 月 12 日

1 投票

There are three steps:
  1. Create an algorithm to define the outliers
  2. Identify the points that meet that definition
  3. Plot those points
Here is an example. You'll need to adapt to your case, for example, by doing this calculation inside of each for loop, and using your own definition of what constitutes an outlier.
Also, I would recommend against using red circles to identify outliers, since your plot is a red line.
% Make up some data
N = 1000;
y = randn(N,1);
y_mean = mean(y);
y_std = std(y);
% Define "outlier" as greater than 2 standard deviations away from the
% mean.
% Find the index to those points
outlierIndex = find(abs(y - y_mean) > 2*y_std);
figure
hold on
% Plot the data
plot(y,'.')
% Plot a red circle around the outliers
plot(outlierIndex,y(outlierIndex),'ro')
test.png

3 件のコメント

timetry2
timetry2 2019 年 10 月 12 日
I ended with a code that looks like this:
figure
for ii = 1:12
y =Data.StrideTimeIntervals_15minTrial.PD(:,ii);
subplot (3,4,ii),plot (y, 'r')
y_mean = mean(y);
y_std = std(y);
title (sprintf('PD %d',ii))
xlabel ('ISI #')
ylabel ('ISI (s)')
axis ([0,500,0.8,1.2])
disp (sprintf('PD %02d Done',ii))
outlierIndex = find(abs(y - y_mean) > 2*y_std);
hold on
plot(y,'.')
plot(outlierIndex,y(outlierIndex),'ro')
end
From here how would I clean the data using a moving average window filter to create a window size of 5 as a new figure? Thank you so much for the help!
the cyclist
the cyclist 2019 年 10 月 12 日
I don't understand this new question. Since your original question seems to be answered, can I suggest you accept my answer, and start a new one, with a more complete description of what you are trying to do?
timetry2
timetry2 2019 年 10 月 12 日
Yes, thank you for your help

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

その他の回答 (0 件)

カテゴリ

質問済み:

2019 年 10 月 12 日

コメント済み:

2019 年 10 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by