How do I plot X = 0 and X = 1/2?

I need to plot X = 0, and X = 1/2 in a 2d graph.
Thank you.

5 件のコメント

Image Analyst
Image Analyst 2016 年 3 月 26 日
Do you have y values? Or is this to be a bar chart?
Poojitha Ariyathilaka
Poojitha Ariyathilaka 2020 年 8 月 31 日
I don't think there you need anymore explanation on the question. How to plot x = 0 and x = 1/2 in MATLAB?
Rik
Rik 2020 年 8 月 31 日
It does though. The answers are different depending on whether you're talking about a bar chart, a line plot (in which case: do you want a line or a point at some y value?), or another option.
Poojitha Ariyathilaka
Poojitha Ariyathilaka 2020 年 9 月 1 日
編集済み: Poojitha Ariyathilaka 2020 年 9 月 1 日
Oh, just don't be kid that much. If you take x = 1/2, you have a perpendicular line across x = 1/2 point on the x-y plane. That's what it needs. If you need you may take a limited range for y, say -500 to +500 (if you can't take it from -infinity to +infinity). When we gonna plot on matlab it's always a liniar graph in general, unless it is specified. So, no point of asking whether it is a bar or a pie... 😁 In the other words, please excuse and show me what is a bar chart of x = 0 or x = 1/2, coz I have never heard of.
Rik
Rik 2020 年 9 月 1 日
I don't think pushing people to provide a good problem definition is childish, if that is what you mean.
Here you have code to create a bar chart for x=0 and x=1/2:
figure(1),clf(1),barh([0 0.5]),axis([-0.5 1.5 0 3])

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

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 26 日
編集済み: Azzi Abdelmalek 2016 年 3 月 26 日

0 投票

x1=0.5*ones(1,10)
x2=zeros(1,10)
y=linspace(-10,10,numel(x))
plot(x1,y,x2,y,'linewidth',2)

3 件のコメント

Poojitha Ariyathilaka
Poojitha Ariyathilaka 2020 年 8 月 31 日
This gives out nothing.
Rik
Rik 2020 年 8 月 31 日
What exact code did you run to come to that conclusion?
Poojitha Ariyathilaka
Poojitha Ariyathilaka 2020 年 9 月 1 日
What else... There is only one code given here. oops

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

Steven Lord
Steven Lord 2020 年 8 月 31 日

0 投票

Use the xline function.

2 件のコメント

Poojitha Ariyathilaka
Poojitha Ariyathilaka 2020 年 9 月 1 日
編集済み: Poojitha Ariyathilaka 2020 年 9 月 1 日
It looks like an answer to the point. But if you please give me a small code with that function to create x = 1/2 line, I would be grateful. Thank you. (R2018a)
Steven Lord
Steven Lord 2020 年 9 月 1 日
This function was introduced in release R2018b so you will not be able to use it since you're using release R2018a. But if you can upgrade to release R2018b or later see the first example on the documentation page for this function.
doc xline

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

カテゴリ

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

製品

タグ

質問済み:

2016 年 3 月 26 日

コメント済み:

Rik
2020 年 9 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by