How can I plot my data corresponding specified x-axis value?
3 views (last 30 days)
Show older comments
I have 15 values which are corresponding 15 specified numbers. I want to plot y but i can't change x-axis values.Matlab automatically sets the x-axis. For example;
y=[1.5 2.5 3.5 4.5]; x=[0.2 1.5 3.5 7.4]; plot(x,y,'.-');
I tried "set","xticklabel" and other things but I did not succeed. How can I solve this problem? How can I plot y which is corresponding each value of x?
0 Comments
Answers (2)
Walter Roberson
on 18 Apr 2014
You can use xlim() to control the x axis range.
I do not think I understand why you consider plot(x,y,'-') to not be plotting the y that corresponds to each value of x ?
0 Comments
mehmet
on 18 Apr 2014
Edited: mehmet
on 18 Apr 2014
1 Comment
Walter Roberson
on 18 Apr 2014
text(x+0.1, y, cellstr(num2str(x(:)) )
would label each point with its x coordinate, if that's the sort of thing you want.
Perhaps you want
set(gca, 'Xtick', x)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!