Plot straight line between points

60 Ansichten (letzte 30 Tage)
Christo van Rensburg
Christo van Rensburg am 2 Mai 2020
Hi everybody,
I'm trying to plot something like this, but just for a number of datapoints.
But keep on getting something like this instead:
I've tried using 'line' but doesn't work and also 'bo-' in the plot command. My code at the moment is:
xVal = [Ax, Bx, Cx];
yVal = [Ay, By, Cy];
plot(xVal, yVal,'bo-'), grid on, hold on
line(xVal, yVal)
Any help is appreciated thanks!

Akzeptierte Antwort

Olawale Ikuyajolu
Olawale Ikuyajolu am 2 Mai 2020
Bearbeitet: Olawale Ikuyajolu am 2 Mai 2020
Click here for the solution to similar problemClick here
  1 Kommentar
Christo van Rensburg
Christo van Rensburg am 2 Mai 2020
I managed to solve it using the following code:
for j = 1:13
xVal = [Bx(j), Ax(j)];
yVal = [By(j), Ay(j)];
plot(xVal, yVal,'bo-'), grid on, hold on
xlim([-0.4 0.4]), ylim([-0.4 0.5])
end
This worked for two points and just created another for-loop for the other two points.
Thanks for the input guys!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

darova
darova am 2 Mai 2020
Try this solution
  2 Kommentare
Christo van Rensburg
Christo van Rensburg am 2 Mai 2020
I tried something like this, but it's not quite what I'm after.
Christo van Rensburg
Christo van Rensburg am 2 Mai 2020
But thanks for your response, see my comment above.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by