Dimension 1 and dimension 2 in octave












1












$begingroup$


I have this in octave:



octave:139> r
r =

3 1
7 2

octave:140> r(2,:)
ans =

7 2

octave:141> r(1,1)
ans = 3
octave:142> r(1,2)
ans = 1


This kind of indexing indicates to me that the dimension 1 is row and dimension 2 is column.



But down below when I specify dimension 1, I get max along the columns (now rows)



octave:143> max(r,,1)
ans =

7 2


And here when I specify dimension 2, I get max along the rows (now colums)



octave:144> max(r,,2)
ans =

3
7


Why so ?










share|cite|improve this question











$endgroup$

















    1












    $begingroup$


    I have this in octave:



    octave:139> r
    r =

    3 1
    7 2

    octave:140> r(2,:)
    ans =

    7 2

    octave:141> r(1,1)
    ans = 3
    octave:142> r(1,2)
    ans = 1


    This kind of indexing indicates to me that the dimension 1 is row and dimension 2 is column.



    But down below when I specify dimension 1, I get max along the columns (now rows)



    octave:143> max(r,,1)
    ans =

    7 2


    And here when I specify dimension 2, I get max along the rows (now colums)



    octave:144> max(r,,2)
    ans =

    3
    7


    Why so ?










    share|cite|improve this question











    $endgroup$















      1












      1








      1





      $begingroup$


      I have this in octave:



      octave:139> r
      r =

      3 1
      7 2

      octave:140> r(2,:)
      ans =

      7 2

      octave:141> r(1,1)
      ans = 3
      octave:142> r(1,2)
      ans = 1


      This kind of indexing indicates to me that the dimension 1 is row and dimension 2 is column.



      But down below when I specify dimension 1, I get max along the columns (now rows)



      octave:143> max(r,,1)
      ans =

      7 2


      And here when I specify dimension 2, I get max along the rows (now colums)



      octave:144> max(r,,2)
      ans =

      3
      7


      Why so ?










      share|cite|improve this question











      $endgroup$




      I have this in octave:



      octave:139> r
      r =

      3 1
      7 2

      octave:140> r(2,:)
      ans =

      7 2

      octave:141> r(1,1)
      ans = 3
      octave:142> r(1,2)
      ans = 1


      This kind of indexing indicates to me that the dimension 1 is row and dimension 2 is column.



      But down below when I specify dimension 1, I get max along the columns (now rows)



      octave:143> max(r,,1)
      ans =

      7 2


      And here when I specify dimension 2, I get max along the rows (now colums)



      octave:144> max(r,,2)
      ans =

      3
      7


      Why so ?







      octave






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Feb 28 '17 at 18:04







      abc

















      asked Feb 28 '17 at 15:23









      abcabc

      1165




      1165






















          2 Answers
          2






          active

          oldest

          votes


















          2












          $begingroup$

          Yeah, that can be a bit confusing. Try to think about it this way:



          1 = which row
          2 = which column



          max(r,,1) = "get the biggest row" (which of course might be a mixture of different rows).



          max(r,,2) = get the biggest column



          Hope this helps to see the reason for this. For matrices it would be possible to use a different convention which might look more intuitve for you. But for higher rank objects (i.e. more than two indices), this convention is the only sensible.






          share|cite|improve this answer









          $endgroup$





















            0












            $begingroup$

            I think a more sensible answer is that the DIM input tells Octave which dimension to take as the independent variable. That is, for example in sum(X, DIM) with DIM =1, at each step the summation is done along the vertical direction (first dimension), which corresponds to the rows as you have observed in your first examples, and the result is a function of the horizontal direction, much like in a double integral.






            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%2f2165462%2fdimension-1-and-dimension-2-in-octave%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2












              $begingroup$

              Yeah, that can be a bit confusing. Try to think about it this way:



              1 = which row
              2 = which column



              max(r,,1) = "get the biggest row" (which of course might be a mixture of different rows).



              max(r,,2) = get the biggest column



              Hope this helps to see the reason for this. For matrices it would be possible to use a different convention which might look more intuitve for you. But for higher rank objects (i.e. more than two indices), this convention is the only sensible.






              share|cite|improve this answer









              $endgroup$


















                2












                $begingroup$

                Yeah, that can be a bit confusing. Try to think about it this way:



                1 = which row
                2 = which column



                max(r,,1) = "get the biggest row" (which of course might be a mixture of different rows).



                max(r,,2) = get the biggest column



                Hope this helps to see the reason for this. For matrices it would be possible to use a different convention which might look more intuitve for you. But for higher rank objects (i.e. more than two indices), this convention is the only sensible.






                share|cite|improve this answer









                $endgroup$
















                  2












                  2








                  2





                  $begingroup$

                  Yeah, that can be a bit confusing. Try to think about it this way:



                  1 = which row
                  2 = which column



                  max(r,,1) = "get the biggest row" (which of course might be a mixture of different rows).



                  max(r,,2) = get the biggest column



                  Hope this helps to see the reason for this. For matrices it would be possible to use a different convention which might look more intuitve for you. But for higher rank objects (i.e. more than two indices), this convention is the only sensible.






                  share|cite|improve this answer









                  $endgroup$



                  Yeah, that can be a bit confusing. Try to think about it this way:



                  1 = which row
                  2 = which column



                  max(r,,1) = "get the biggest row" (which of course might be a mixture of different rows).



                  max(r,,2) = get the biggest column



                  Hope this helps to see the reason for this. For matrices it would be possible to use a different convention which might look more intuitve for you. But for higher rank objects (i.e. more than two indices), this convention is the only sensible.







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered Feb 28 '17 at 16:10









                  SimonSimon

                  2,285216




                  2,285216























                      0












                      $begingroup$

                      I think a more sensible answer is that the DIM input tells Octave which dimension to take as the independent variable. That is, for example in sum(X, DIM) with DIM =1, at each step the summation is done along the vertical direction (first dimension), which corresponds to the rows as you have observed in your first examples, and the result is a function of the horizontal direction, much like in a double integral.






                      share|cite|improve this answer









                      $endgroup$


















                        0












                        $begingroup$

                        I think a more sensible answer is that the DIM input tells Octave which dimension to take as the independent variable. That is, for example in sum(X, DIM) with DIM =1, at each step the summation is done along the vertical direction (first dimension), which corresponds to the rows as you have observed in your first examples, and the result is a function of the horizontal direction, much like in a double integral.






                        share|cite|improve this answer









                        $endgroup$
















                          0












                          0








                          0





                          $begingroup$

                          I think a more sensible answer is that the DIM input tells Octave which dimension to take as the independent variable. That is, for example in sum(X, DIM) with DIM =1, at each step the summation is done along the vertical direction (first dimension), which corresponds to the rows as you have observed in your first examples, and the result is a function of the horizontal direction, much like in a double integral.






                          share|cite|improve this answer









                          $endgroup$



                          I think a more sensible answer is that the DIM input tells Octave which dimension to take as the independent variable. That is, for example in sum(X, DIM) with DIM =1, at each step the summation is done along the vertical direction (first dimension), which corresponds to the rows as you have observed in your first examples, and the result is a function of the horizontal direction, much like in a double integral.







                          share|cite|improve this answer












                          share|cite|improve this answer



                          share|cite|improve this answer










                          answered Dec 12 '18 at 18:06









                          arsaKasraarsaKasra

                          1011




                          1011






























                              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%2f2165462%2fdimension-1-and-dimension-2-in-octave%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

                              Ellipse (mathématiques)

                              Quarter-circle Tiles

                              Mont Emei