# how to plot ellipse around poincare map of RR intervals

29 views (last 30 days)
Dominik Smolinsky on 11 Apr 2022
Answered: William Rose on 21 Apr 2022
Hello guys, i have poincare map (where on x is RR interval and on y axis is RR interval+1) and i want to plot ellipse around this poincare map.
My code:
figure()
subplot(131)
plot(RR_x_1,RR_y_1,".")
axis([-2e5 10e5 0e5 10e5])
title("0-5min 4km/hod")
subplot(132)
plot(RR_x_2,RR_y_2,".")
axis([-2e5 10e5 0e5 10e5])
title("5-10min 8km/hod")
subplot(133)
plot(RR_x_3,RR_y_3,".")
axis([-2e5 10e5 0e5 10e5])
title("10-15min 10km/hod")
This is output of my code - poincare maps : Torsten on 11 Apr 2022

William Rose on 21 Apr 2022
Here is code that draws an ellipse that is designed to capture 95% of the data points. By adjusting a value in the code, you could chage it to capture approximately 90% or 99%, etc. The ellipse size is based on the assumption that the data are independently normally distributed about perpendicular axes, which may not be the X and Y axes. The actual data in the attached file is the center of pressure of a blindfolded subject, recorded at 100 Hz.
% conf_ellipse.m WCR 10/17/2002, 20160303
% Draws a 95% confidence ellipse around xy data.
% Data is read in from a file.
% Plots the data, the ellipse, and the principal components.
% The number sqrt(5.99)=2.45 appears because prob(X>5.99)=0.95, if X~chi squared with 2 d.f.
% Replace 2.45 with sqrt(4.61)=2.15 to get the 90% confidence ellipse.
% Replace 2.45 with sqrt(9.21)=3.03 to get the 99% confidence ellipse.
%filename=input('Enter name of text file containing the data: ','s');
filename='copdata.txt';
mean_d=mean(d);
cov_mtx=cov(d);
[V,D]=eig(cov_mtx);
semimaj=[mean_d;mean_d+2.45*sqrt(D(1,1))*V(:,1)'];
semimin=[mean_d;mean_d+2.45*sqrt(D(2,2))*V(:,2)'];
theta=linspace(0,2*pi,41)';
ellipse=2.45*sqrt(D(1,1))*cos(theta)*V(:,1)'+2.45*sqrt(D(2,2))*sin(theta)*V(:,2)'+ones(size(theta))*mean_d;
ellipse99area=pi*9.21*sqrt(D(1,1)*D(2,2));
ellipse95area=pi*5.99*sqrt(D(1,1)*D(2,2));
ellipse90area=pi*4.61*sqrt(D(1,1)*D(2,2));
%% Plot results.
hold off; plot(d(:,1),d(:,2),'bx'); hold on; axis equal
plot(semimaj(:,1),semimaj(:,2),'r','LineWidth',2); hold on
plot(semimin(:,1),semimin(:,2),'r','LineWidth',2); hold on
plot(ellipse(:,1),ellipse(:,2),'g','LineWidth',2) Try the code above. Good luck.