How do I plot a discrete set of points say [x1,x2,...,xn] along the real line?
12 次查看(过去 30 天)
显示 更早的评论
Suppose I have a set of points [x1,x2,...,xn] then how do I plot them on the real line? . The reason I am asking is that I want to plot the eigen values of a Gaussian Orthogonal Ensemble along the x axis. So using eig(A) , I get an array of size n(lets say 10) . So I want to plot those 10 points along the x axis. That is I simply want to plot these real numbers on the x-axis. It does not matter if I plot it on say the line y=1 . Given a pen and paper , I would just draw a line and mark them with dots. How do I do this on MATLAB?
0 个评论
采纳的回答
Cameron
2023-2-13
编辑:Cameron
2023-2-14
A = gallery('lehmer',4); %example data
x = eig(A); %your eigenvalues
yValue = 0; %you can make this 1 or whatever you want
plot(x,yValue*ones(1,length(x)),'ko') %plot
3 个评论
Cameron
2023-2-14
A = gallery('lehmer',4); %example data
x = eig(A); %your eigenvalues
yValue = 0; %you can make this 1 or whatever you want
plot(x,yValue*ones(1,length(x)),'k-o','MarkerFaceColor','k') %plot
idx = 1 - mod(bsxfun(@plus,(1:length(x))',1),2) == 1; %alternating ones and zeros
yloc = yValue*ones(1,length(x)); %set default value for yloc
offset = 0.2; %offset from your line
yloc(idx) = yloc(idx) + offset; %offset 1,3,5,7, etc
yloc(~idx) = yloc(~idx) - offset; %offset 2,4,6,8, etc
text(x,yloc,string(x)) %add annotation
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!