How I draw a line?
Mostrar comentarios más antiguos
I have only the value of one co-ordinate(x,y) , slope(m) and constant(c). How i draw a line in matlab?
5 comentarios
madhan ravi
el 22 de Nov. de 2018
linewidth is increased right ? then what's the problem ?
Md Ashraf
el 22 de Nov. de 2018
Adam
el 22 de Nov. de 2018
Tell it to plot further then. The length is determined by the values you give it - i.e. P1 and P2
Md Ashraf
el 22 de Nov. de 2018
Adam
el 22 de Nov. de 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.
Respuestas (2)
Geoff Hayes
el 22 de Nov. de 2018
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.
1 comentario
Image Analyst
el 23 de Nov. de 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.
Categorías
Más información sobre Signal Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

