How do I treat the results of Fit as text?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



For example



"Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


produces the garbled output



Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
r r r


How do I treat the results of Fit or FittedModel as text?










share|improve this question



























    up vote
    2
    down vote

    favorite
    1












    I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



    For example



    "Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


    produces the garbled output



    Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
    0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
    r r r


    How do I treat the results of Fit or FittedModel as text?










    share|improve this question

























      up vote
      2
      down vote

      favorite
      1









      up vote
      2
      down vote

      favorite
      1






      1





      I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



      For example



      "Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


      produces the garbled output



      Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
      0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
      r r r


      How do I treat the results of Fit or FittedModel as text?










      share|improve this question















      I would like to take the results of Fit (or any FittedModel) and treat them as text, including making substitutions for the variables. But I can't figure out how to do this.



      For example



      "Subscript[I, m]/Subscript[I, r]" <> " = " <> ToString[Fit[currentRatio[32],1,x,x^2,x^3,x]/.x->"Subscript[I, r]"]


      produces the garbled output



      Subscript[I, m]/Subscript[I, r] = -6 2 -10 3
      0.591585 + 0.00126235 I - 1.75804 10 I + 8.08979 10 I
      r r r


      How do I treat the results of Fit or FittedModel as text?







      fitting text






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 5 mins ago









      m_goldberg

      82.5k869190




      82.5k869190










      asked 1 hour ago









      orome

      5,84323680




      5,84323680




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
          ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
          x -> "Subscript[I, r]", StandardForm]


          enter image description here



          With InputForm inplace of StandardForm we get




          "Subscript[I, m]/Subscript[I, r] = 0. +
          0.9999999999999991*"Subscript[I, r]" +
          2.511131286529154*^-15*"Subscript[I, r]"^2 +
          0.9999999999999988*"Subscript[I, r]"^3"




          Note: ToString >> Details and Options:




          ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




           ToString[x^2]


          enter image description here



           ToString[x^2, StandardForm]


          enter image description here



           ToString[x^2, InputForm]


          enter image description here






          share|improve this answer





























            up vote
            2
            down vote













            Just use Row:



            Row[
            Subscript[I, m]/Subscript[I, r] ,
            " = ",
            Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
            x -> Subscript[I, r]
            ]


            enter image description here






            share|improve this answer






















            • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
              – orome
              1 hour ago










            • With Row[...] you can combine strings and Style-objects!
              – Ulrich Neumann
              1 hour ago










            • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
              – orome
              58 mins ago










            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: "387"
            ;
            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: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183303%2fhow-do-i-treat-the-results-of-fit-as-text%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
            ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
            x -> "Subscript[I, r]", StandardForm]


            enter image description here



            With InputForm inplace of StandardForm we get




            "Subscript[I, m]/Subscript[I, r] = 0. +
            0.9999999999999991*"Subscript[I, r]" +
            2.511131286529154*^-15*"Subscript[I, r]"^2 +
            0.9999999999999988*"Subscript[I, r]"^3"




            Note: ToString >> Details and Options:




            ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




             ToString[x^2]


            enter image description here



             ToString[x^2, StandardForm]


            enter image description here



             ToString[x^2, InputForm]


            enter image description here






            share|improve this answer


























              up vote
              2
              down vote













              "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
              ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
              x -> "Subscript[I, r]", StandardForm]


              enter image description here



              With InputForm inplace of StandardForm we get




              "Subscript[I, m]/Subscript[I, r] = 0. +
              0.9999999999999991*"Subscript[I, r]" +
              2.511131286529154*^-15*"Subscript[I, r]"^2 +
              0.9999999999999988*"Subscript[I, r]"^3"




              Note: ToString >> Details and Options:




              ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




               ToString[x^2]


              enter image description here



               ToString[x^2, StandardForm]


              enter image description here



               ToString[x^2, InputForm]


              enter image description here






              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
                ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                x -> "Subscript[I, r]", StandardForm]


                enter image description here



                With InputForm inplace of StandardForm we get




                "Subscript[I, m]/Subscript[I, r] = 0. +
                0.9999999999999991*"Subscript[I, r]" +
                2.511131286529154*^-15*"Subscript[I, r]"^2 +
                0.9999999999999988*"Subscript[I, r]"^3"




                Note: ToString >> Details and Options:




                ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




                 ToString[x^2]


                enter image description here



                 ToString[x^2, StandardForm]


                enter image description here



                 ToString[x^2, InputForm]


                enter image description here






                share|improve this answer














                "Subscript[I, m]/Subscript[I, r]" <> " = " <> 
                ToString[Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                x -> "Subscript[I, r]", StandardForm]


                enter image description here



                With InputForm inplace of StandardForm we get




                "Subscript[I, m]/Subscript[I, r] = 0. +
                0.9999999999999991*"Subscript[I, r]" +
                2.511131286529154*^-15*"Subscript[I, r]"^2 +
                0.9999999999999988*"Subscript[I, r]"^3"




                Note: ToString >> Details and Options:




                ToString supports the same set of options as OpenAppend, with default settings FormatType->OutputForm, PageWidth->Infinity, TotalWidth->Infinity.




                 ToString[x^2]


                enter image description here



                 ToString[x^2, StandardForm]


                enter image description here



                 ToString[x^2, InputForm]


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 54 mins ago

























                answered 1 hour ago









                kglr

                164k8188388




                164k8188388




















                    up vote
                    2
                    down vote













                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here






                    share|improve this answer






















                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      1 hour ago










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      1 hour ago










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      58 mins ago














                    up vote
                    2
                    down vote













                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here






                    share|improve this answer






















                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      1 hour ago










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      1 hour ago










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      58 mins ago












                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here






                    share|improve this answer














                    Just use Row:



                    Row[
                    Subscript[I, m]/Subscript[I, r] ,
                    " = ",
                    Fit[Table[x, x + x^3, x, 0, 1, .1], 1, x, x^2, x^3, x] /.
                    x -> Subscript[I, r]
                    ]


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 6 mins ago









                    m_goldberg

                    82.5k869190




                    82.5k869190










                    answered 1 hour ago









                    Ulrich Neumann

                    4,955413




                    4,955413











                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      1 hour ago










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      1 hour ago










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      58 mins ago
















                    • If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                      – orome
                      1 hour ago










                    • With Row[...] you can combine strings and Style-objects!
                      – Ulrich Neumann
                      1 hour ago










                    • It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                      – orome
                      58 mins ago















                    If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                    – orome
                    1 hour ago




                    If I try to join that with a string as in the OP I get the same error: "StringJoin::string: String expected at position 2 in...".
                    – orome
                    1 hour ago












                    With Row[...] you can combine strings and Style-objects!
                    – Ulrich Neumann
                    1 hour ago




                    With Row[...] you can combine strings and Style-objects!
                    – Ulrich Neumann
                    1 hour ago












                    It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                    – orome
                    58 mins ago




                    It never fails that no matter what I'm trying to do, I eventually reach the point where I kick myself and ask: Why didn't I just do this in Python!
                    – orome
                    58 mins ago

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183303%2fhow-do-i-treat-the-results-of-fit-as-text%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery