Reputation: 123
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?
Put even simply , I just want to plot [1,2,3,4,5] on the x axis with prominent dots.
So what I would ideally want is a prominent axis and prominent dots on it according to [x1,...,xn] and also display the labels .
What I have tried is
x=[1,2,3,4] plot(x,0) or plot(x,1). But it shows just a blank graph. Can anyone help me out with this? I am an absolute noob in MATLAB.
I was expecting the line y=0 or y=1 with dots marking the points (1,0),(2,0),(3,0),(4,0) or (1,1),...,(4,1).
Upvotes: 2
Views: 104
Reputation: 1307
" I was expecting the line y=0 or y=1 with dots marking the points (1,0),(2,0),(3,0),(4,0) or (1,1),...,(4,1)."
The following script will do that:
hold('on') % Do all plots in the same figure
axis([0,5,-0.1 1.1]);grid('on') % Set the axes and turn on the grid
x = 1:4 % x = [1 2 3 4]
plot(x,ones(size(x)),'b') % Line y=1
plot(x,zeros(size(x)),'b') % Line y=0
scatter(x,zeros(size(x)),'MarkerFaceColor','b') % Points: (1,0),(2,0),(3,0),(4,0)
scatter(x,ones(size(x)),'MarkerFaceColor','b') % Points: (1,1),(2,1),(3,1),(4,1)
The result:
Upvotes: 2