I have a question about plot. Plesase help me.

4 views (last 30 days)
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.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 20 Dec 2013
Edited: Azzi Abdelmalek on 20 Dec 2013
s=get(gca,'ylim')
hold on;
plot([a a],s)

More Answers (1)

Geert
Geert on 20 Dec 2013
Edited: Geert on 20 Dec 2013
% 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')

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!