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.

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 20 Déc 2013
Modifié(e) : Azzi Abdelmalek le 20 Déc 2013
s=get(gca,'ylim')
hold on;
plot([a a],s)

2 commentaires

For your case
hold on;
plot([a a],[3 5])
thank you very much

Connectez-vous pour commenter.

Plus de réponses (1)

Geert
Geert le 20 Déc 2013
Modifié(e) : Geert le 20 Déc 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')

3 commentaires

Azzi Abdelmalek
Azzi Abdelmalek le 20 Déc 2013
You don't need 500 points to plot a line
Geert
Geert le 20 Déc 2013
Corrected it...
thanks very much

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by