I have a question about plot. Plesase help me.

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

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

Più risposte (1)

Geert
Geert il 20 Dic 2013
Modificato: Geert il 20 Dic 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')

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by