Help with ODE solving using RK method in Matlab











up vote
-1
down vote

favorite












I have the following ode



$idot{x_n}(t)=-x_{n+1}(t)-x_{n-1}(t)+g~ x_n(t)$ with I.C. $phi(0)=-2cos(2.5)$ and $g=1$.



where $dot{x_n}=frac{dx_n}{dt}$, $n$ are discrete points in space, and $x$ is the value of field on each point.



However, I am unable to produce desired plot of $x_n$ (at a fixed time) along y-axis vs $n$ on x-axis.
I am trying to solve it via Matlab ODE45 but unable to get around it. We could take say $-5leq nleq5$, i.e., 11 total space points to start. Thanks










share|cite|improve this question


























    up vote
    -1
    down vote

    favorite












    I have the following ode



    $idot{x_n}(t)=-x_{n+1}(t)-x_{n-1}(t)+g~ x_n(t)$ with I.C. $phi(0)=-2cos(2.5)$ and $g=1$.



    where $dot{x_n}=frac{dx_n}{dt}$, $n$ are discrete points in space, and $x$ is the value of field on each point.



    However, I am unable to produce desired plot of $x_n$ (at a fixed time) along y-axis vs $n$ on x-axis.
    I am trying to solve it via Matlab ODE45 but unable to get around it. We could take say $-5leq nleq5$, i.e., 11 total space points to start. Thanks










    share|cite|improve this question
























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I have the following ode



      $idot{x_n}(t)=-x_{n+1}(t)-x_{n-1}(t)+g~ x_n(t)$ with I.C. $phi(0)=-2cos(2.5)$ and $g=1$.



      where $dot{x_n}=frac{dx_n}{dt}$, $n$ are discrete points in space, and $x$ is the value of field on each point.



      However, I am unable to produce desired plot of $x_n$ (at a fixed time) along y-axis vs $n$ on x-axis.
      I am trying to solve it via Matlab ODE45 but unable to get around it. We could take say $-5leq nleq5$, i.e., 11 total space points to start. Thanks










      share|cite|improve this question













      I have the following ode



      $idot{x_n}(t)=-x_{n+1}(t)-x_{n-1}(t)+g~ x_n(t)$ with I.C. $phi(0)=-2cos(2.5)$ and $g=1$.



      where $dot{x_n}=frac{dx_n}{dt}$, $n$ are discrete points in space, and $x$ is the value of field on each point.



      However, I am unable to produce desired plot of $x_n$ (at a fixed time) along y-axis vs $n$ on x-axis.
      I am trying to solve it via Matlab ODE45 but unable to get around it. We could take say $-5leq nleq5$, i.e., 11 total space points to start. Thanks







      differential-equations numerical-methods matlab






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked 22 hours ago









      AtoZ

      135




      135



























          active

          oldest

          votes











          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',
          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%2f3004826%2fhelp-with-ode-solving-using-rk-method-in-matlab%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3004826%2fhelp-with-ode-solving-using-rk-method-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

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]