How do I plot a discrete set of points say [x1,x2,...,xn] along the real line?
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Arghyadeep
el 13 de Feb. de 2023
Comentada: Cameron
el 14 de Feb. de 2023
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 comentarios
Respuesta aceptada
Cameron
el 13 de Feb. de 2023
Editada: Cameron
el 14 de Feb. de 2023
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 comentarios
Cameron
el 14 de Feb. de 2023
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!