R中矩阵的图形数值范围

问题描述 投票:0回答:1

我如何在R中绘制厄米矩阵的数值范围?例如,我有以下矩阵:


a = matrix(c(8+5i,6,0,14+5i),2,2,byrow = T)
a
eigen(a)

数值范围是一个椭圆,其焦点为矩阵的特征值例如。

qplot(Re(c(14,8)), Im(c(5i,5i)), geom="point")

但是我怎么画椭圆旅馆R。我尝试了这个但失败了:


ellipseFun <- function(center = c(0,0),axis = c(0,0), npoints = 100){
  phi =  pi/3
  tt  =  seq(0,2*pi,length.out = npoints)
  xx  =  center[1] + axis[1]*cos(t)*cos(phi) - axis[2]*sin(t)*sin(phi)
  yy  =  center[2] + axis[1]*cos(t)*cos(phi) + axis[2]*sin(t)*cos(phi)
  return(data.frame(x = xx, y = yy))
}
dat <- ellipseFun(c(14,8),c(20,20),npoints = 100)
head(dat)
dat1 = data.frame(x=c(14,8),y=c(0,0));dat1
p = ggplot (dat1, aes (x = x, y = y))+
  geom_point()
p
p+geom_path(data=dat)

r matrix ellipse
1个回答
0
投票

我承认我的线性代数有点生锈(或者一开始几乎不存在,但这是您要找的吗?

ggplot(dat1, aes(x=x,y=y)) + 
  geom_point() + 
  geom_path(data=dat, aes(x=x,y=y))

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.