How do I plot an “unarranged” array1 vs array2 in MATLAB?












0












$begingroup$


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.).










share|cite|improve this question









$endgroup$








  • 1




    $begingroup$
    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.')".
    $endgroup$
    – JimmyK4542
    Dec 28 '18 at 23:57












  • $begingroup$
    @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
    $endgroup$
    – Carlos Vázquez Monzón
    Dec 29 '18 at 0:03










  • $begingroup$
    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.
    $endgroup$
    – clmundergrad
    Dec 29 '18 at 0:46










  • $begingroup$
    What do you want connecting lines for?
    $endgroup$
    – littleO
    Dec 29 '18 at 1:28
















0












$begingroup$


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.).










share|cite|improve this question









$endgroup$








  • 1




    $begingroup$
    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.')".
    $endgroup$
    – JimmyK4542
    Dec 28 '18 at 23:57












  • $begingroup$
    @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
    $endgroup$
    – Carlos Vázquez Monzón
    Dec 29 '18 at 0:03










  • $begingroup$
    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.
    $endgroup$
    – clmundergrad
    Dec 29 '18 at 0:46










  • $begingroup$
    What do you want connecting lines for?
    $endgroup$
    – littleO
    Dec 29 '18 at 1:28














0












0








0





$begingroup$


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.).










share|cite|improve this question









$endgroup$




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.).







matlab






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Dec 28 '18 at 23:27









Carlos Vázquez MonzónCarlos Vázquez Monzón

1738




1738








  • 1




    $begingroup$
    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.')".
    $endgroup$
    – JimmyK4542
    Dec 28 '18 at 23:57












  • $begingroup$
    @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
    $endgroup$
    – Carlos Vázquez Monzón
    Dec 29 '18 at 0:03










  • $begingroup$
    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.
    $endgroup$
    – clmundergrad
    Dec 29 '18 at 0:46










  • $begingroup$
    What do you want connecting lines for?
    $endgroup$
    – littleO
    Dec 29 '18 at 1:28














  • 1




    $begingroup$
    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.')".
    $endgroup$
    – JimmyK4542
    Dec 28 '18 at 23:57












  • $begingroup$
    @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
    $endgroup$
    – Carlos Vázquez Monzón
    Dec 29 '18 at 0:03










  • $begingroup$
    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.
    $endgroup$
    – clmundergrad
    Dec 29 '18 at 0:46










  • $begingroup$
    What do you want connecting lines for?
    $endgroup$
    – littleO
    Dec 29 '18 at 1:28








1




1




$begingroup$
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.')".
$endgroup$
– JimmyK4542
Dec 28 '18 at 23:57






$begingroup$
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.')".
$endgroup$
– JimmyK4542
Dec 28 '18 at 23:57














$begingroup$
@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
$endgroup$
– Carlos Vázquez Monzón
Dec 29 '18 at 0:03




$begingroup$
@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
$endgroup$
– Carlos Vázquez Monzón
Dec 29 '18 at 0:03












$begingroup$
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.
$endgroup$
– clmundergrad
Dec 29 '18 at 0:46




$begingroup$
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.
$endgroup$
– clmundergrad
Dec 29 '18 at 0:46












$begingroup$
What do you want connecting lines for?
$endgroup$
– littleO
Dec 29 '18 at 1:28




$begingroup$
What do you want connecting lines for?
$endgroup$
– littleO
Dec 29 '18 at 1:28










1 Answer
1






active

oldest

votes


















1












$begingroup$

Try



[array1_sorted, array1_order] = sort(array1);
array2_sorted = array2(array1_order, : );





share|cite|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3055387%2fhow-do-i-plot-an-unarranged-array1-vs-array2-in-matlab%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1












    $begingroup$

    Try



    [array1_sorted, array1_order] = sort(array1);
    array2_sorted = array2(array1_order, : );





    share|cite|improve this answer









    $endgroup$


















      1












      $begingroup$

      Try



      [array1_sorted, array1_order] = sort(array1);
      array2_sorted = array2(array1_order, : );





      share|cite|improve this answer









      $endgroup$
















        1












        1








        1





        $begingroup$

        Try



        [array1_sorted, array1_order] = sort(array1);
        array2_sorted = array2(array1_order, : );





        share|cite|improve this answer









        $endgroup$



        Try



        [array1_sorted, array1_order] = sort(array1);
        array2_sorted = array2(array1_order, : );






        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 28 '18 at 23:42









        caveraccaverac

        14.6k31130




        14.6k31130






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3055387%2fhow-do-i-plot-an-unarranged-array1-vs-array2-in-matlab%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei