draw a line from one point to other in matlab
Answers
Answered by
3
hey I am harshmaster and I hope that this answer will help you in your studies.
% Generate sample data
thePoints = 3*rand(20,2);
% Find the mean.
referencePoint = mean(thePoints, 1)
xMean = referencePoint(1);
yMean = referencePoint(2);
% Plot the points.
scatter(thePoints(:, 1), thePoints(:, 2), 'LineWidth', 3);
hold on;
plot(referencePoint(1), referencePoint(2),...
'ro', 'MarkerSize', 15, 'LineWidth', 3);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
grid on;
% Plot lines from the mean to all the other points.
for k = 1 : size(thePoints, 1)
x = thePoints(k, 1);
y = thePoints(k, 2);
line([x, xMean], [y, yMean], 'Color', 'k');
end
please brainlieast me
% Generate sample data
thePoints = 3*rand(20,2);
% Find the mean.
referencePoint = mean(thePoints, 1)
xMean = referencePoint(1);
yMean = referencePoint(2);
% Plot the points.
scatter(thePoints(:, 1), thePoints(:, 2), 'LineWidth', 3);
hold on;
plot(referencePoint(1), referencePoint(2),...
'ro', 'MarkerSize', 15, 'LineWidth', 3);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
grid on;
% Plot lines from the mean to all the other points.
for k = 1 : size(thePoints, 1)
x = thePoints(k, 1);
y = thePoints(k, 2);
line([x, xMean], [y, yMean], 'Color', 'k');
end
please brainlieast me
harshmaster:
please brainlieast me
Answered by
0
Answer:
Draw lines between points
11 44 2 9. 11 44 5 8. 2 1 6 11. 2 1 10 3.
x = [11 11 2 1; 2, 5, 6, 10]; y = [44 44 1 1; 9 8 11 3]; plot (x, y).
load coordinates. txt; edit coordinates. txt; x1= [coordinates(:, 1); coordinates(:, 3)]; y1 = [coordinates(:, 2); coordinates(:, 4)]; plot (x1, y1).
Similar questions