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

5 commentaires

madhan ravi
madhan ravi le 22 Nov 2018
linewidth is increased right ? then what's the problem ?
Md Ashraf
Md Ashraf le 22 Nov 2018
Actually,I want to increase the length of a line not linewidth. @madhan ravi
Adam
Adam le 22 Nov 2018
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 le 22 Nov 2018
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 le 22 Nov 2018
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.

Connectez-vous pour commenter.

Réponses (2)

Geoff Hayes
Geoff Hayes le 22 Nov 2018

0 votes

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 le 22 Nov 2018
Modifié(e) : Md Ashraf le 22 Nov 2018

0 votes

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 commentaire

Image Analyst
Image Analyst le 23 Nov 2018
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.

Connectez-vous pour commenter.

Tags

Question posée :

le 22 Nov 2018

Commenté :

le 23 Nov 2018

Community Treasure Hunt

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

Start Hunting!

Translated by