How would I plot and connect two points properly?
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a total of 4 numeric input boxes. The first two label x1 and y2 and the second two label x2 and y2. I am able to plot both coordinates on my graph, but I cant seem to be able to connect them with a line. Also when i plot them they do not plot to scale. Meaning I have to scroll through my graph in order to find the two coordinates. For example if i plot my x1 and x2 as (3,6) and my x2 and y2 as (4,7) i can only see my x1 and y1 coordinate and i would have to scroll to find my x2 and y2 because my x and y values would go by decimal increments(3.1,3.2,3.3,3.4....).
This is my code:
function PlotButtonPushed(app, event)
x=app.X1EditField.Value;
y=app.Y1EditField.Value;
a=app.X2EditField.Value;
b=app.Y2EditField.Value;
hold(app.UIAxes,"on");
plot(app.UIAxes, x, y,'mo--');
plot(app.UIAxes, a, b, 'md');
end
end
댓글 수: 0
답변 (1개)
Image Analyst
2023년 9월 10일
Instead of those two plot calls, do it this way.
x=1;
y=3;
a=2;
b=1;
plot([x, a], [y, b], 'm-d', 'LineWidth', 2, 'MarkerSize', 15);
grid on;
댓글 수: 2
Image Analyst
2023년 9월 11일
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
