Putting measurement unit and origin in plot

On the mesh grid, I would like on the x-axis in the far right end below the last value to put x1 and also the measurement unit, in my case, cm/s. And at the point (0,0) to write (0,0). Is it possible?
Thank you in advance.

 Accepted Answer

I am not exactly certain what you want, however the xlim and text functions would likely be appropriate.

4 Comments

That would be relatively straightforward. See the documentation sections on Axes Properties and NumericRuler Properties for details.
Example —
x_grn = 2;
y_grn = 3;
figure
plot([0 x_grn], [1 1]*y_grn, '--g') % Horizontal Green Dashed Line
hold on
plot([1 1]*x_grn, [0 y_grn], '--g') % Vertical Green Dashed Line
scatter(x_grn,y_grn,[],'g','o','filled') % Green Lines Intersection Point
scatter(0,0,'o','filled') % Origin Point
hold off
grid
text(0, 0, '(0,0)', 'Color','m', 'Horiz','left', 'Vert','bottom')
text(x_grn,y_grn,sprintf('(%.0f,%.0f)',x_grn,y_grn), 'Color','g', 'Horiz','left', 'Vert','bottom')
axis([-4 4 -4 4]) % Axis Limits
Ax = gca;
xl = xlim;
Ax.XTick = min(xl) : max(xl); % Tick Values
yl = ylim;
Ax.YTick = min(yl) : max(yl); % Tick Values
Ax.XAxisLocation = 'origin';
Ax.YAxisLocation = 'origin';
axis('square')
This should get you started. I leave the rest to you.
.
As always, my pleasure!

Sign in to comment.

More Answers (0)

Products

Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!