I have a question about plot. Plesase help me.

I want to draw a line x = a perpendicular to the x axis in matlab. How do I do ? (with a = constant) value y from 3 to 5.

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 20 日
編集済み: Azzi Abdelmalek 2013 年 12 月 20 日

1 投票

s=get(gca,'ylim')
hold on;
plot([a a],s)

2 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 20 日
For your case
hold on;
plot([a a],[3 5])
Nguyen Trong Nhan
Nguyen Trong Nhan 2013 年 12 月 20 日
thank you very much

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

その他の回答 (1 件)

Geert
Geert 2013 年 12 月 20 日
編集済み: Geert 2013 年 12 月 20 日

1 投票

% define your constant:
a = 5;
% define y limits
ymin = -10;
ymax = 10;
% define x and y values
x = a*ones(2,1);
y = linspace(ymin,ymax,length(x));
% plot the result
figure()
plot(x,y,'r-')
xlabel('x')
ylabel('y')
title('plot of x = a')

3 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 20 日
You don't need 500 points to plot a line
Geert
Geert 2013 年 12 月 20 日
Corrected it...
Nguyen Trong Nhan
Nguyen Trong Nhan 2013 年 12 月 20 日
thanks very much

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

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by