0

I have to plot two arrays:

array1= [ 0.6321 0.6640 0.6997 0.8574 0.8824 0.9222 0.0893 0.1310 0.1600 0.3251 0.4008 0.7528 0.7985 0.9871 0.0417 0.2209 0.2694]

array2 = [-40.8700 -46.9600 -47.3900 -19.8500 -13.4700 -5.7820 49.4100 58.6600 63.2000 45.6000 17.8800 -45.5000 -38.9800 27.2700 32.4500 63.3800 54.7800]

As you see, the first array is unarranged, so when I plot them together this mess happens:

enter image description here

Which is obvious, since plot() join the points together and they go back and forth. How I make this problem go away? I could order the arrays, but that's not what I want (I want to plot the point, (0.6321,-40.8700),(0.6640,-46.9600), etc.).

  • 1
    Are you just looking to plot a single dot at each point without any connecting lines? If so, try the command "plot(array1, array2, 'b.')". – JimmyK4542 Dec 28 '18 at 23:57
  • @JimmyK4542 I want connecting lines, but I don't wanna them to go back and forth. Just joining the points, you know? That way I'll have a proper plot – Carlos Vázquez Monzón Dec 29 '18 at 00:03
  • I might be wrong, someone please correct me if I am, but this seems more appropriate for a programming/comp.sci exchange than it does the math exchange - since it's about programming and not really math. Just for next time. – clm Dec 29 '18 at 00:46
  • What do you want connecting lines for? – littleO Dec 29 '18 at 01:28

1 Answers1

1

Try

[array1_sorted, array1_order] = sort(array1);
array2_sorted = array2(array1_order, : );
caverac
  • 19,345