I have only the value of one co-ordinate(x,y) , slope(m) and constant(c). How i draw a line in matlab?

5 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 22 日
linewidth is increased right ? then what's the problem ?
Md Ashraf
Md Ashraf 2018 年 11 月 22 日
Actually,I want to increase the length of a line not linewidth. @madhan ravi
Adam
Adam 2018 年 11 月 22 日
Tell it to plot further then. The length is determined by the values you give it - i.e. P1 and P2
Md Ashraf
Md Ashraf 2018 年 11 月 22 日
I have only the value of one co-ordinate(x,y) , slope(m) and constant(c). How i draw a line in matlab?
Sorry for the mistake.
Adam
Adam 2018 年 11 月 22 日
Well, you have y = mx + c
Choose a second 'x' value, calculate the 'y' and now you have two coordinates with which to plot a line.

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

回答 (2 件)

Geoff Hayes
Geoff Hayes 2018 年 11 月 22 日

0 投票

Md - you could use linspace to generate some points along the x-axis and then feed that into your equation to get your corresponding y values. For example, since you have one coordinate take the x (call it say x1) and do
X = linspace(x1-10, x1+10, 100);
The above will generate 100 linearly spaced elements within the interval [x1-10, x1+10]. If you want more elements, then increase this number. If you want a larger or more narrow interval, then adjust how much you add and subtract from x1.
Md Ashraf
Md Ashraf 2018 年 11 月 22 日
編集済み: Md Ashraf 2018 年 11 月 22 日

0 投票

i want to extend the line which in circle. It is not possible to found second co-ordinate(x2,y2). Is matlab any built-in function for it?
my desired output

1 件のコメント

Image Analyst
Image Analyst 2018 年 11 月 23 日
Use polyfit() on the coordinates in the blob. Then use polyval() to get the x (column) value at row 1, and the last row. Untested code below. Adapt/fix as needed.
[rows, columns] = find(oneBlob);
coefficients = polyfit(columns, row, 1);
x = 1 : columns;
y = polyval(coefficients, x)
% Extract only those y inside the image.
goodY = y >= 1 & y <= rows;
y = y(goodY);
x = x(goodY);
plot(x, y, 'r-', 'LineWidth', 2);
Make sure oneBlob is a binary image with only that one blob in it, not both of them.

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2018 年 11 月 22 日

コメント済み:

2018 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by