Plotting a line x=constant

107 Ansichten (letzte 30 Tage)
cyberdyne
cyberdyne am 21 Sep. 2011
Beantwortet: Svitlana Strunina am 29 Mär. 2021
Hi,
What is a good way to plot a straight line parallel to y-axis for a particular x value?
I've used this code but the line is dotted
x=3;
y=0:0.001:0.3; %How much is long
plot(x, y, 'LineWidth', 10) % but is not large enough
  1 Kommentar
Ram Lakha Meena
Ram Lakha Meena am 27 Aug. 2020
This is what i did and the result:
clear
clc
close all
x=3;
y=0:0.001:0.3; %How much is long
plot(x, y, 'LineWidth', 10) % but is not large enough

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Grzegorz Knor
Grzegorz Knor am 21 Sep. 2011
Another option:
line([x x],[y(1) y(end)],'LineWidth',10)

Weitere Antworten (3)

Francisco Williams
Francisco Williams am 24 Aug. 2020
You can use xline command

Paulo Silva
Paulo Silva am 21 Sep. 2011
plot(x*ones(size(y)), y, 'LineWidth', 10)
or
plot(x*ones(1,size(y,2)), y, 'LineWidth', 10)

Svitlana Strunina
Svitlana Strunina am 29 Mär. 2021
xline(3);
https://www.mathworks.com/help/matlab/ref/xline.html

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by