Reputation: 20014
How to make lines start at 0, when plotting a matrix using the plot
function?
To be more precise, this is what I want to solve:
Upvotes: 2
Views: 7684
Reputation: 748
I was also facing the same problem and I resolved it by changing the Y-scale to 'linear' from 'log'. On figure window navigate Edit-> Axes Properties... Then select Y-axis and change the Y-scale to 'linear'.
Upvotes: 0
Reputation: 1
Maybe with "xlim" will be enought.
It this case you can just write:
xlim([0,32]);
In a more generic case you might need to use:
a1=min(x);
a2=max(x);
xlim([a1,a2])
Upvotes: 0
Reputation: 18488
See the help for the plot
command: When using the plot command with a single argument, Matlab implicitly plots the argument versus its index, so plot([3,5,9])
is equivalent to plot([1,2,3], [3,5,9])
. More in general, plot(y)
corresponds to plot(1:length(y), y)
for a vector and plot(M)
corresponds to plot(1:size(M, 1), M)
for a matrix.
To plot starting from zero, you should thus do plot(0:length(y) - 1, y)
for vectors, or plot(0:size(M, 1) - 1, M)
for matrices, as in your case.
Upvotes: 4