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.

 採用された回答

Star Strider
Star Strider 2022 年 9 月 25 日

0 投票

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

4 件のコメント

Alexandra Roxana
Alexandra Roxana 2022 年 9 月 25 日
I would like something like this: https://en.wikipedia.org/wiki/Cartesian_coordinate_system#/media/File:Cartesian-coordinate-system.svg and below x the measurement unit.
Star Strider
Star Strider 2022 年 9 月 25 日
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.
.
Alexandra Roxana
Alexandra Roxana 2022 年 9 月 26 日
Thank you very much!
Star Strider
Star Strider 2022 年 9 月 26 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by