Like the picture above. How can I make the picture more smooth. Or narrow down the
One way to smooth the line involves non-linear interpolation of data between sample points. When you do plot(x,y,'o-'), MATLAB automatically plots a connect-the-dots style piece-wise linear series. However, you can plot without the automatic connecting lines, using just markers for the data points, and plot your own smoothed series (or just plot the smoothed series!). For example, start with the default connecting lines:
x = 1:10;
y = rand(numel(x),1);
plot(x,y,'r-o')
Now, one way to generate "smoothed" data is by using non-linear interpolation for the curve (no longer a line) between data points. We can use interp1 with the 'cubic'
interpolation method to do this:
xx = 1:0.1:10; % line is inherently higher sample rate
yy = interp1(x,y,xx,'cubic');
plot(x,y,'bo',xx,yy,'k-')
What this really boils down to is not a MATLAB trick at all -- just plot interpolated data. However, ask yourself if you would be better off just plotting the actual data. There is good reason why plot
just does connect-the-dots!
Regarding the y axis range, you can set the min and max without touching the x axis via ylim as follows,
ylim([yMin yMax])