From: Uwe B. <ou...@ma...> - 2017-10-24 21:20:12
|
Hi I am using more and more org mode, a long with auctex and matlab.el. Orgmode comes in handy if I write a document which contains (matlab) code which I want to execute, but the rest of the file maybe text, which I can then export to latex. So a typical file looks like Given \droppoints \begin{displaymath} \begin{cases} \frac{du}{dt}&= -t u^2,\\ u(0)&=1, \end{cases} \end{displaymath} Solve using ... #+BEGIN_solution #+begin_src matlab :results output latex :exports results :eval never-export f=@(t,y)[-t*y^2]; [t,y]=mieuler(f,[0 1],1,2); disp('\begin{align*}') fprintf('t = [%g \\qquad %g \\quad %g] \\\\\n', t) fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) disp('\end{align*}') #+end_src Now I can execute the matlab code in that org file using C-c C-c ( org-ctrl-c-ctrl-c, the *one-ring-to-rule-them-all* function in orgmode. Thanks thanks to a function provided to me by John Kitchin it executes matlab. It is as follows: (defun org-babel-execute:matlab (body params) (interactive "P") (let* ((current-file (buffer-file-name)) (code (org-element-property :value (org-element-context))) (result-params (cdr (assoc :result-params params))) m-file md5-hash) (with-temp-buffer (insert code) (setq md5-hash (md5 (buffer-string)) mbuffer (format "*m-%s*" md5-hash) m-file (format "m-%s.m" md5-hash))) ;; create the file to run (with-temp-file m-file (insert code)) (let ((results (shell-command-to-string (concat "/usr/local/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) (delete-file m-file) (when results ;; strip out >> (setq results (replace-regexp-in-string ">> " "" results)) ;; remove first 10 lines that are the header. ;; matlab license seem to expire soon, so 5 warning lines are added ;; change first 10 to first 15 lines (setq results (mapconcat 'identity (nthcdr 10 (split-string results "\n")) "\n"))) (org-babel-result-cond result-params results)))) The problem of that code is that it starts matlab every time I execute C-c C-c . There seems to be a python based kernel around which avoids this, but I thought that maybe with a bit of hacking one could use the elisp based matlab-shell and the corresponding functions. Anybody has an idea, Eric? Needless to say that I played a bit around but did get it to work.... Regards Uwe Brauer |
From: Cumhur E. <cum...@gm...> - 2017-10-25 03:40:18
|
Hi, Assuming that matlab-mode and matlab-shell are working, org-babel natively supports matlab code execution. Your org-babel-execute:matlab overrides the org-babel defaults in ob-octave.el, which can be inspected there. I enable the babel support in .emacs as (org-babel-do-load-languages 'org-babel-load-languages '( (latex . t) (plantuml . t) (java . t) (matlab . t) (C . t) (csharp . t) (table . t) ) ) after this, C-c C-c will execute the code, but the next snippet in .emacs makes the sessions continuous, and simplifies the arguments given each time (setq org-babel-default-header-args:matlab '((:session . "*MATLAB*") (:results . "silent") ) ) More an org answer than matlab.el, but I hope these help. Cumhur Erkut > On Oct 24, 2017, at 22:53, Uwe Brauer <ou...@ma...> wrote: > > Hi > > I am using more and more org mode, a long with auctex and matlab.el. > Orgmode comes in handy if I write a document which contains (matlab) > code which I want to execute, but the rest of the file maybe text, which > I can then export to latex. > > So a typical file looks like > > Given > \droppoints > \begin{displaymath} > \begin{cases} > \frac{du}{dt}&= -t u^2,\\ > u(0)&=1, > \end{cases} > \end{displaymath} > > Solve using ... > > > #+BEGIN_solution > #+begin_src matlab :results output latex :exports results :eval never-export > f=@(t,y)[-t*y^2]; > [t,y]=mieuler(f,[0 1],1,2); > disp('\begin{align*}') > fprintf('t = [%g \\qquad %g \\quad %g] \\\\\n', t) > fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) > disp('\end{align*}') > #+end_src > > Now I can execute the matlab code in that org file using > > C-c C-c ( org-ctrl-c-ctrl-c, the *one-ring-to-rule-them-all* function in > orgmode. > > Thanks thanks to a function provided to me by John Kitchin it executes > matlab. > > It is as follows: > > (defun org-babel-execute:matlab (body params) > (interactive "P") > (let* ((current-file (buffer-file-name)) > (code (org-element-property :value (org-element-context))) > (result-params (cdr (assoc :result-params params))) > m-file > md5-hash) > (with-temp-buffer > (insert code) > (setq md5-hash (md5 (buffer-string)) > mbuffer (format "*m-%s*" md5-hash) > m-file (format "m-%s.m" md5-hash))) > ;; create the file to run > (with-temp-file m-file > (insert code)) > (let ((results (shell-command-to-string > (concat > "/usr/local/bin/matlab " > "-nodesktop -nojvm -nosplash -nodisplay <" > m-file)))) > (delete-file m-file) > (when results > ;; strip out >> > (setq results (replace-regexp-in-string ">> " "" results)) > ;; remove first 10 lines that are the header. > ;; matlab license seem to expire soon, so 5 warning lines are added > ;; change first 10 to first 15 lines > (setq results (mapconcat 'identity > (nthcdr 10 (split-string results "\n")) > "\n"))) > (org-babel-result-cond result-params > results)))) > > The problem of that code is that it starts matlab every time I execute > C-c C-c . There seems to be a python based kernel around which avoids > this, but I thought that maybe with a bit of hacking one could use the > elisp based matlab-shell and the corresponding functions. > > Anybody has an idea, Eric? > Needless to say that I played a bit around but did get it to work.... > > Regards > > Uwe Brauer > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Matlab-emacs-discuss mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss |
From: Eric L. <Eri...@ma...> - 2017-10-31 21:43:03
|
MATLAB mode has a command to execute region in the MATLAB Shell from a .M file. I see no reason why you couldn't re-use that. It may be it needs updating to also start the shell, or to chdir if there is a function, or something like that. Eric -----Original Message----- From: Uwe Brauer [mailto:ou...@ma...] Sent: Tuesday, October 24, 2017 4:54 PM To: matlab-emacs-discuss <mat...@li...> Subject: [Matlab-emacs-discuss] executing matlab in org mode files (using the matlab-shell) Hi I am using more and more org mode, a long with auctex and matlab.el. Orgmode comes in handy if I write a document which contains (matlab) code which I want to execute, but the rest of the file maybe text, which I can then export to latex. So a typical file looks like Given \droppoints \begin{displaymath} \begin{cases} \frac{du}{dt}&= -t u^2,\\ u(0)&=1, \end{cases} \end{displaymath} Solve using ... #+BEGIN_solution #+begin_src matlab :results output latex :exports results :eval never-export f=@(t,y)[-t*y^2]; [t,y]=mieuler(f,[0 1],1,2); disp('\begin{align*}') fprintf('t = [%g \\qquad %g \\quad %g] \\\\\n', t) fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) disp('\end{align*}') #+end_src Now I can execute the matlab code in that org file using C-c C-c ( org-ctrl-c-ctrl-c, the *one-ring-to-rule-them-all* function in orgmode. Thanks thanks to a function provided to me by John Kitchin it executes matlab. It is as follows: (defun org-babel-execute:matlab (body params) (interactive "P") (let* ((current-file (buffer-file-name)) (code (org-element-property :value (org-element-context))) (result-params (cdr (assoc :result-params params))) m-file md5-hash) (with-temp-buffer (insert code) (setq md5-hash (md5 (buffer-string)) mbuffer (format "*m-%s*" md5-hash) m-file (format "m-%s.m" md5-hash))) ;; create the file to run (with-temp-file m-file (insert code)) (let ((results (shell-command-to-string (concat "/usr/local/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) (delete-file m-file) (when results ;; strip out >> (setq results (replace-regexp-in-string ">> " "" results)) ;; remove first 10 lines that are the header. ;; matlab license seem to expire soon, so 5 warning lines are added ;; change first 10 to first 15 lines (setq results (mapconcat 'identity (nthcdr 10 (split-string results "\n")) "\n"))) (org-babel-result-cond result-params results)))) The problem of that code is that it starts matlab every time I execute C-c C-c . There seems to be a python based kernel around which avoids this, but I thought that maybe with a bit of hacking one could use the elisp based matlab-shell and the corresponding functions. Anybody has an idea, Eric? Needless to say that I played a bit around but did get it to work.... Regards Uwe Brauer ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Matlab-emacs-discuss mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss |
From: Uwe B. <ou...@ma...> - 2017-10-25 09:29:37
|
>>> "Cumhur" == Cumhur Erkut <cum...@gm...> writes: > Hi, > Assuming that matlab-mode and matlab-shell are working, org-babel > natively supports matlab code execution. > Your org-babel-execute:matlab overrides the org-babel defaults in > ob-octave.el, which can be inspected there. > I enable the babel support in .emacs as > (org-babel-do-load-languages > 'org-babel-load-languages > '( > (setq org-babel-default-header-args:matlab > '((:session . "*MATLAB*") > (:results . "silent") > ) > ) > More an org answer than matlab.el, but I hope these help. Right: your code uses the matlab-shell, which writes its results in the *MATLAB* shell buffer, but I want the result (at least optional) to be written in the org buffer. So a typical org file after executing matlab looks like ,---- | | \droppoints | \begin{displaymath} | \begin{cases} | \frac{du}{dt}&= -t u^2,\\ | u(0)&=1, | \end{cases} | \end{displaymath} | | Solve using ... | | | #+BEGIN_solution | #+begin_src matlab :results output latex :exports results :eval never-export | f=@(t,y)[-t*y^2]; | [t,y]=mieuler(f,[0 1],1,2); | disp('\begin{align*}') | fprintf('t = [%g \\qquad %g \\quad %g] \\\\\n', t) | fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) | disp('\end{align*}') | #+end_src | | #+RESULTS: | #+BEGIN_EXPORT latex | \begin{align*} | t = [0 \qquad 0.5 \quad 1] \\ | y = [1 \qquad 1 \qquad 0.75] | \end{align*} | #+END_EXPORT | `---- This is what the hack does and it does it nicely, the only problem is that every time I execute the code matlab is started again, and for more recent versions of matlab this can take some time. So the question is whether the hack I used, could use the matlab-shell. Uwe Brauer |
From: Uwe B. <ou...@ma...> - 2017-10-31 21:27:13
|
>>> "Eric" == Eric Ludlam <Eri...@ma...> writes: > MATLAB mode has a command to execute region in the MATLAB Shell from a > .M file. I see no reason why you couldn't re-use that. > It may be it needs updating to also start the shell, or to chdir if > there is a function, or something like that. Hm suppose the shell is running. The core of his function are the following lines (let ((results (shell-command-to-string (concat "/usr/local/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) So are you saying I should try (switch-to-buffer m-file) (find-file m-file) ;? None worked (let ((results (matlab-shell-save-and-go) (delete-file m-file) rest of code))) Hm this did not work, so most likely I am not taking care of something elementary here. Uwe |
From: Eric L. <Eri...@ma...> - 2017-11-03 15:16:54
|
Sorry for not being more precise. Inside 'matlab-shell-save-and-go' is infrastructure for building something custom for org-mode. For example, how it looks for a shell buffer and creates on only if needed, and how it updates the history (which you could remove) and how it executes the string. It is similar to run-region in how it works w/ the shell buffer. In a different part of the thread, you wanted to capture the output to insert into org-mode. 'matlab-shell-run-command' will capture the output to display in a help buffer. You could probably use its mechanisms to capture the output from the shell to display where you need it. If you want to capture images from any figures created, there is nothing for that. You'd need to add something the matlab-emacs toolbox for capturing and saving images in a way that Emacs could then pick up the files. Eric -----Original Message----- From: Uwe Brauer [mailto:ou...@ma...] Sent: Tuesday, October 31, 2017 5:27 PM To: Eric Ludlam <Eri...@ma...> Cc: Uwe Brauer <ou...@ma...>; matlab-emacs-discuss <mat...@li...> Subject: Re: [Matlab-emacs-discuss] executing matlab in org mode files (using the matlab-shell) >>> "Eric" == Eric Ludlam <Eri...@ma...> writes: > MATLAB mode has a command to execute region in the MATLAB Shell from a > .M file. I see no reason why you couldn't re-use that. > It may be it needs updating to also start the shell, or to chdir if > there is a function, or something like that. Hm suppose the shell is running. The core of his function are the following lines (let ((results (shell-command-to-string (concat "/usr/local/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) So are you saying I should try (switch-to-buffer m-file) (find-file m-file) ;? None worked (let ((results (matlab-shell-save-and-go) (delete-file m-file) rest of code))) Hm this did not work, so most likely I am not taking care of something elementary here. Uwe |
From: Eric L. <Eri...@ma...> - 2017-11-03 15:03:49
|
Ah, sorry I can't be more help. It has been many years since I worked on that code, and I don't use Emacs much anymore. There are accommodations in the function's I referenced for the ML command line to make sure it doesn't interrupting anything a user might be typing in that would be important for your use case. It might be worth trying the Matlab help stuff in matlab-mode/matlab-shell to see if it still works. This is code that will call help, and put output into a separate buffer. I haven't tested it in ages, so if it isn't working in ML shell, that might explain any issues you're bumping into with org mode. Eric -----Original Message----- From: Uwe Brauer [mailto:ou...@ma...] Sent: Friday, November 03, 2017 10:39 AM To: Eric Ludlam <Eri...@ma...> Cc: Uwe Brauer <ou...@ma...>; matlab-emacs-discuss <mat...@li...> Subject: Re: [Matlab-emacs-discuss] executing matlab in org mode files (using the matlab-shell) >>> "Eric" == Eric Ludlam <Eri...@ma...> writes: > Sorry for not being more precise. > Inside 'matlab-shell-save-and-go' is infrastructure for building > something custom for org-mode. For example, how it looks for a shell > buffer and creates on only if needed, and how it updates the history > (which you could remove) and how it executes the string. It is similar > to run-region in how it works w/ the shell buffer. Yeah I tried to debug it and to understand its structure. The matlab-shell-command is, at least for me, maybe the most complex part of the code. On the other hand the crucial parts of John's code are the lines (let ((results (shell-command-to-string (concat "/usr/local/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) So I hoped somebody with a better understanding of the matlab-shell-command could give me a hint, but it seems that the merge between John's code and matlab-shell is much more complicated. > In a different part of the thread, you wanted to capture the output to > insert into org-mode. 'matlab-shell-run-command' will capture the > output to display in a help buffer. You could probably use its > mechanisms to capture the output from the shell to display where you > need it. Yes I did and John's code does precisely this. I asked the same question on the orgmode list and John replied. The only problem with his code is that it uses the command line matlab command and so starts every time matlab, when the code is executed. > If you want to capture images from any figures created, there is > nothing for that. You'd need to add something the matlab-emacs toolbox > for capturing and saving images in a way that Emacs could then pick up > the files. No that is ok, I hoped orgmode could take that part as well but all my attempts failed. Uwe |
From: Uwe B. <ou...@ma...> - 2017-11-03 14:39:07
|
>>> "Eric" == Eric Ludlam <Eri...@ma...> writes: > Sorry for not being more precise. > Inside 'matlab-shell-save-and-go' is infrastructure for building > something custom for org-mode. For example, how it looks for a shell > buffer and creates on only if needed, and how it updates the history > (which you could remove) and how it executes the string. It is similar > to run-region in how it works w/ the shell buffer. Yeah I tried to debug it and to understand its structure. The matlab-shell-command is, at least for me, maybe the most complex part of the code. On the other hand the crucial parts of John's code are the lines (let ((results (shell-command-to-string (concat "/usr/local/bin/matlab " "-nodesktop -nojvm -nosplash -nodisplay <" m-file)))) So I hoped somebody with a better understanding of the matlab-shell-command could give me a hint, but it seems that the merge between John's code and matlab-shell is much more complicated. > In a different part of the thread, you wanted to capture the output to > insert into org-mode. 'matlab-shell-run-command' will capture the > output to display in a help buffer. You could probably use its > mechanisms to capture the output from the shell to display where you > need it. Yes I did and John's code does precisely this. I asked the same question on the orgmode list and John replied. The only problem with his code is that it uses the command line matlab command and so starts every time matlab, when the code is executed. > If you want to capture images from any figures created, there is > nothing for that. You'd need to add something the matlab-emacs toolbox > for capturing and saving images in a way that Emacs could then pick up > the files. No that is ok, I hoped orgmode could take that part as well but all my attempts failed. Uwe |
From: Uwe B. <ou...@ma...> - 2017-11-04 15:35:00
Attachments:
smime.p7s
|
<html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style> </head> <body bidimailui-detected-decoding-type="latin-charset" bgcolor="#FFFFFF" text="#000000"> <div class="moz-cite-prefix">On 11/03/2017 03:47 PM, Eric Ludlam wrote:<br> </div> <blockquote cite="mid:MWH...@MW..." type="cite"> <pre wrap="">Ah, sorry I can't be more help. It has been many years since I worked on that code, and I don't use Emacs much anymore. There are accommodations in the function's I referenced for the ML command line to make sure it doesn't interrupting anything a user might be typing in that would be important for your use case. </pre> </blockquote> <br> Ok fair enough. I think I made some progress but still have a small<br> problem, maybe you might remember and help. :-D<br> <br> John's code consists of:<br> <br> - cleaning the matlab code in orgmode mode: (font lock stuff etc)<br> and collect it.<br> <br> - create a temporally file and insert the clean matlab commands.<br> <br> - run a external matlab process via<br> "/usr/local/bin/matlab " "-nodesktop <" m-file<br> <br> - clean the result and insert it in the original buffer.<br> <br> So my solution is to use the matlab-shell-collect-command-output<br> function. So my code is:<br> <br> - cleaning the matlab code in orgmode mode: (font lock stuff etc)<br> and collect it.<br> <br> - run (matlab-shell-collect-command-output code) where code<br> corresponds to the clean code from step one which John inserts in<br> temp buffer.<br> <br> - clean the result and insert it in the original buffer.<br> <br> <br> The only problem is that the output of the<br> /usr/local/bin/matlab -nodesktop < m-file<br> <br> And (matlab-shell-collect-command-output code)<br> is slightly different.<br> Take the following example.<br> <br> f=@(t,y)[-t*y^2];<br> [t,y]=ode45(f,[0 1],1);<br> t=[t(1),t(end)];<br> y=[y(1),y(end)];<br> disp('\begin{align*}')<br> fprintf('t = [%g \\quad %g] \\\\\n', t)<br> fprintf('y = [%g \\qquad %g] \n', y)<br> disp('\end{align*}')<br> <br> The external matlab command does not include the fprintf in his output.<br> I have collected the output of both approaches including the result of<br> the cleaning function.<br> <br> So there are two possibilities. <br> <br> - Modify matlab-shell-collect-command-output so that it behaves closer to<br> /usr/local/bin/matlab -nodesktop < m-file<br> <br> - modify the cleaning function (which I don't understand but could<br> ask John about it).<br> <br> (when results<br> ;; strip out >><br> (setq results (replace-regexp-in-string ">> " "" results))<br> ;; remove first 10 lines that are the header.<br> (setq results (mapconcat 'identity<br> (nthcdr 10 (split-string results "\n"))<br> "\n")))<br> <br> <br> Any comment is more than welcome. Here is the output of both commands<br> <br> <br> <br> Uwe<br> <br> <div id="content"> <div id="outline-container-org102ba5b" class="outline-2"> <h2 id="org102ba5b"><span class="section-number-2">1</span> Matlab and the cleaning</h2> <div class="outline-text-2" id="text-1"> </div> <div id="outline-container-org7653ede" class="outline-3"> <h3 id="org7653ede"><span class="section-number-3">1.1</span> Result Matlab (John)</h3> <div class="outline-text-3" id="text-1-1"> <p> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n">www.mathworks.com.\n\n</a>>> >> >> >> >> \\begin{align*}\n>> t = [0 \\quad1] \\\\\n>> y = [1 \\qquad0.666667] \n>> \\end{align*}\n>> "<br> Stop<br> [2 times]<br> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n">www.mathworks.com.\n\n</a>>> >> >> >> >> \\begin{align*}\n>> t = [0 \\quad1] \\\\\n>> y = [1 \\qquad0.666667] \n>> \\end{align*}\n>> "<br> [3 times]<br> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n">www.mathworks.com.\n\n</a>>> >> >> >> >> \\begin{align*}\n>> t = [0 \\quad1] \\\\\n>> y = [1 \\qquad0.666667] \n>> \\end{align*}\n>> "<br> </p> <p> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n\\begin">www.mathworks.com.\n\n\\begin</a>{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n\\begin">www.mathworks.com.\n\n\\begin</a>{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> [5 times]<br> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n\\begin">www.mathworks.com.\n\n\\begin</a>{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: (#1="" " < M A T L A B (R) >" " Copyright 1984-2012 The MathWorks, Inc." " R2012a (7.14.0.739) 32-bit (glnx86)" " February 9, 2012" #1# " " "To get started, type one of these: helpwin, helpdesk, or demo." "For product information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com">www.mathworks.com</a>." " " "\\begin{align*}" "t = [0 \\quad1] \\\\" "y = [1 \\qquad0.666667] " "\\end{align*}" #1#)<br> </p> </div> </div> <div id="outline-container-org1203d4a" class="outline-3"> <h3 id="org1203d4a"><span class="section-number-3">1.2</span> Result cleaning (John)</h3> <div class="outline-text-3" id="text-1-2"> <p> Result: ("\\begin{align*}" "t = [0 \\quad1] \\\\" "y = [1 \\qquad0.666667] " "\\end{align*}" "")<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> [2 times]<br> Result: ("replace" "output" "latex")<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> </div> </div> <div id="outline-container-org417a7b3" class="outline-3"> <h3 id="org417a7b3"><span class="section-number-3">1.3</span> Result Matlab (Shell)</h3> <div class="outline-text-3" id="text-1-3"> <p> Result: "f=@(t,y)[-t*y<sup>2</sup>];\n[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ndisp('\\end{align*}')\n"<br> </p> <p> Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\n>> fprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n"<br> [2 times]<br> Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\n>> fprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n"<br> [3 times]<br> Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\n>> fprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n"<br> </p> <p> Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> [5 times]<br> Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: ("[t,y]=ode45(f,[0 1],1);" "t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}" "fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)" "t = [0 \\quad1] \\\\" "fprintf('y = [%g \\\\qquad%g] \\n', y)" "y = [1 \\qquad0.666667] " "disp('\\end{align*}')" "\\end{align*}" #1="" #1# #1#)<br> </p> </div> </div> <div id="outline-container-org40deade" class="outline-3"> <h3 id="org40deade"><span class="section-number-3">1.4</span> Result cleaning</h3> <div class="outline-text-3" id="text-1-4"> <p> Result: ("t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}" "fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)" "t = [0 \\quad1] \\\\" "fprintf('y = [%g \\\\qquad%g] \\n', y)" "y = [1 \\qquad0.666667] " "disp('\\end{align*}')" "\\end{align*}" #1="" #1# #1#)<br> </p> <p> Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> </div> </div> </div> </div> <div id="postamble" class="status"> <p class="date">Created: 2017-11-04 Sat 15:26</p> <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> </div> <br> <div id="content"> <div id="outline-container-org102ba5b" class="outline-2"> <h2 id="org102ba5b"><span class="section-number-2">1</span> Matlab and the cleaning</h2> <div class="outline-text-2" id="text-1"> </div> <div id="outline-container-org7653ede" class="outline-3"> <h3 id="org7653ede"><span class="section-number-3">1.1</span> Result Matlab (John)</h3> <div class="outline-text-3" id="text-1-1"> <p> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n">www.mathworks.com.\n\n</a>>> >> >> >> >> \\begin{align*}\n>> t = [0 \\quad1] \\\\\n>> y = [1 \\qquad0.666667] \n>> \\end{align*}\n>> "<br> Stop<br> [2 times]<br> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n">www.mathworks.com.\n\n</a>>> >> >> >> >> \\begin{align*}\n>> t = [0 \\quad1] \\\\\n>> y = [1 \\qquad0.666667] \n>> \\end{align*}\n>> "<br> [3 times]<br> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n">www.mathworks.com.\n\n</a>>> >> >> >> >> \\begin{align*}\n>> t = [0 \\quad1] \\\\\n>> y = [1 \\qquad0.666667] \n>> \\end{align*}\n>> "<br> </p> <p> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n\\begin">www.mathworks.com.\n\n\\begin</a>{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n\\begin">www.mathworks.com.\n\n\\begin</a>{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> [5 times]<br> Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com.\n\n\\begin">www.mathworks.com.\n\n\\begin</a>{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: (#1="" " < M A T L A B (R) >" " Copyright 1984-2012 The MathWorks, Inc." " R2012a (7.14.0.739) 32-bit (glnx86)" " February 9, 2012" #1# " " "To get started, type one of these: helpwin, helpdesk, or demo." "For product information, visit <a class="moz-txt-link-abbreviated" href="http://www.mathworks.com">www.mathworks.com</a>." " " "\\begin{align*}" "t = [0 \\quad1] \\\\" "y = [1 \\qquad0.666667] " "\\end{align*}" #1#)<br> </p> </div> </div> <div id="outline-container-org1203d4a" class="outline-3"> <h3 id="org1203d4a"><span class="section-number-3">1.2</span> Result cleaning (John)</h3> <div class="outline-text-3" id="text-1-2"> <p> Result: ("\\begin{align*}" "t = [0 \\quad1] \\\\" "y = [1 \\qquad0.666667] " "\\end{align*}" "")<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> [2 times]<br> Result: ("replace" "output" "latex")<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> <p> Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n"<br> </p> </div> </div> <div id="outline-container-org417a7b3" class="outline-3"> <h3 id="org417a7b3"><span class="section-number-3">1.3</span> Result Matlab (Shell)</h3> <div class="outline-text-3" id="text-1-3"> <p> Result: "f=@(t,y)[-t*y<sup>2</sup>];\n[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ndisp('\\end{align*}')\n"<br> </p> <p> Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\n>> fprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n"<br> [2 times]<br> Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\n>> fprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n"<br> [3 times]<br> Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\n>> fprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n"<br> </p> <p> Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> [5 times]<br> Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: ("[t,y]=ode45(f,[0 1],1);" "t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}" "fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)" "t = [0 \\quad1] \\\\" "fprintf('y = [%g \\\\qquad%g] \\n', y)" "y = [1 \\qquad0.666667] " "disp('\\end{align*}')" "\\end{align*}" #1="" #1# #1#)<br> </p> </div> </div> <div id="outline-container-org40deade" class="outline-3"> <h3 id="org40deade"><span class="section-number-3">1.4</span> Result cleaning</h3> <div class="outline-text-3" id="text-1-4"> <p> Result: ("t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}" "fprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)" "t = [0 \\quad1] \\\\" "fprintf('y = [%g \\\\qquad%g] \\n', y)" "y = [1 \\qquad0.666667] " "disp('\\end{align*}')" "\\end{align*}" #1="" #1# #1#)<br> </p> <p> Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> <p> Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nt= [0 \\quad1] \\\\\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ny= [1 \\qquad0.666667] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n"<br> </p> </div> </div> </div> </div> <div id="postamble" class="status"> <p class="date">Created: 2017-11-04 Sat 15:26</p> <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> </div> <br> </body> </html> |
From: Eric L. <Eri...@ma...> - 2017-11-06 17:49:50
|
It looks like an echoing feature is turned on, where input into ML is echo'd back out again. There's a variable for describing what ML does since the echo depends on platform or some-such. I think it's been 't' for a long time. Maybe in your cleaned code, put all the code on one line with no CRs, and sub in a , when there is no line ending. Then you could clean out the input code. Alternately, put it into a tmp file as before, and run that, and clean out the name of the tmp command. I don't have a Linux box to test my MATLABs on to fiddle around with echo features. Sorry. Eric From: Uwe Brauer [mailto:ou...@ma...] Sent: Saturday, November 04, 2017 11:35 AM To: Eric Ludlam <Eri...@ma...> Cc: matlab-emacs-discuss <mat...@li...> Subject: almost doneRe: [Matlab-emacs-discuss] executing matlab in org mode files (using the matlab-shell) On 11/03/2017 03:47 PM, Eric Ludlam wrote: Ah, sorry I can't be more help. It has been many years since I worked on that code, and I don't use Emacs much anymore. There are accommodations in the function's I referenced for the ML command line to make sure it doesn't interrupting anything a user might be typing in that would be important for your use case. Ok fair enough. I think I made some progress but still have a small problem, maybe you might remember and help. :-D John's code consists of: - cleaning the matlab code in orgmode mode: (font lock stuff etc) and collect it. - create a temporally file and insert the clean matlab commands. - run a external matlab process via "/usr/local/bin/matlab " "-nodesktop <" m-file - clean the result and insert it in the original buffer. So my solution is to use the matlab-shell-collect-command-output function. So my code is: - cleaning the matlab code in orgmode mode: (font lock stuff etc) and collect it. - run (matlab-shell-collect-command-output code) where code corresponds to the clean code from step one which John inserts in temp buffer. - clean the result and insert it in the original buffer. The only problem is that the output of the /usr/local/bin/matlab -nodesktop < m-file And (matlab-shell-collect-command-output code) is slightly different. Take the following example. f=@(t,y)[-t*y^2]; [t,y]=ode45(f,[0 1],1); t=[t(1),t(end)]; y=[y(1),y(end)]; disp('\begin{align*}') fprintf('t = [%g \\quad<file://quad> %g] \\\\\n<file://n>', t) fprintf('y = [%g \\qquad<file://qquad> %g] \n', y) disp('\end{align*}') The external matlab command does not include the fprintf in his output. I have collected the output of both approaches including the result of the cleaning function. So there are two possibilities. - Modify matlab-shell-collect-command-output so that it behaves closer to /usr/local/bin/matlab -nodesktop < m-file - modify the cleaning function (which I don't understand but could ask John about it). (when results ;; strip out >> (setq results (replace-regexp-in-string ">> " "" results)) ;; remove first 10 lines that are the header. (setq results (mapconcat 'identity (nthcdr 10 (split-string results "\n")) "\n"))) Any comment is more than welcome. Here is the output of both commands Uwe 1 Matlab and the cleaning 1.1 Result Matlab (John) Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n<http://www.mathworks.com./n/n>>> >> >> >> >> \\begin{align*}\n<file://begin%7balign*%7d/n>>> t = [0 \\quad1<file://quad1>] \\\\\n<file://n>>> y = [1 \\qquad0.666667<file://qquad0.666667>] \n>> \\end{align*}\n<file://end%7balign*%7d/n>>> " Stop [2 times] Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n<http://www.mathworks.com./n/n>>> >> >> >> >> \\begin{align*}\n<file://begin%7balign*%7d/n>>> t = [0 \\quad1<file://quad1>] \\\\\n<file://n>>> y = [1 \\qquad0.666667<file://qquad0.666667>] \n>> \\end{align*}\n<file://end%7balign*%7d/n>>> " [3 times] Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n<http://www.mathworks.com./n/n>>> >> >> >> >> \\begin{align*}\n<file://begin%7balign*%7d/n>>> t = [0 \\quad1<file://quad1>] \\\\\n<file://n>>> y = [1 \\qquad0.666667<file://qquad0.666667>] \n>> \\end{align*}\n<file://end%7balign*%7d/n>>> " Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n\\begin<http://www.mathworks.com./n/n/begin>{align*}\nt= [0 \\quad1<file://quad1>] \\\\\ny<file://ny>= [1 \\qquad0.666667<file://qquad0.666667>] \n\\end{align*}\n" Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n\\begin<http://www.mathworks.com./n/n/begin>{align*}\nt= [0 \\quad1<file://quad1>] \\\\\ny<file://ny>= [1 \\qquad0.666667<file://qquad0.666667>] \n\\end{align*}\n" [5 times] Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n\\begin<http://www.mathworks.com./n/n/begin>{align*}\nt= [0 \\quad1<file://quad1>] \\\\\ny<file://ny>= [1 \\qquad0.666667<file://qquad0.666667>] \n\\end{align*}\n" Result: (#1="" " < M A T L A B (R) >" " Copyright 1984-2012 The MathWorks, Inc." " R2012a (7.14.0.739) 32-bit (glnx86)" " February 9, 2012" #1# " " "To get started, type one of these: helpwin, helpdesk, or demo." "For product information, visit www.mathworks.com<http://www.mathworks.com>." " " "\\begin{align*}<file://begin%7balign*%7d>" "t = [0 \\quad1<file://quad1>] \\\\" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "\\end{align*}<file://end%7balign*%7d>" #1#) 1.2 Result cleaning (John) Result: ("\\begin{align*}<file://begin%7balign*%7d>" "t = [0 \\quad1<file://quad1>] \\\\" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "\\end{align*}<file://end%7balign*%7d>" "") Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" [2 times] Result: ("replace" "output" "latex") Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" 1.3 Result Matlab (Shell) Result: "f=@(t,y)[-t*y2];\n[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ndisp('\\end{align*}')\n" Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\n<file://n>>> fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n" [2 times] Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\n<file://n>>> fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n" [3 times] Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\n<file://n>>> fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n" Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" [5 times] Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: ("[t,y]=ode45(f,[0 1],1);" "t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}<file://begin%7balign*%7d>" "fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)" "t = [0 \\quad1<file://quad1>] \\\\" "fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "disp('\\end{align*}')" "\\end{align*}<file://end%7balign*%7d>" #1="" #1# #1#) 1.4 Result cleaning Result: ("t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}<file://begin%7balign*%7d>" "fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)" "t = [0 \\quad1<file://quad1>] \\\\" "fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "disp('\\end{align*}')" "\\end{align*}<file://end%7balign*%7d>" #1="" #1# #1#) Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Created: 2017-11-04 Sat 15:26 Validate<http://validator.w3.org/check?uri=referer> 1 Matlab and the cleaning 1.1 Result Matlab (John) Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n<http://www.mathworks.com./n/n>>> >> >> >> >> \\begin{align*}\n<file://begin%7balign*%7d/n>>> t = [0 \\quad1<file://quad1>] \\\\\n<file://n>>> y = [1 \\qquad0.666667<file://qquad0.666667>] \n>> \\end{align*}\n<file://end%7balign*%7d/n>>> " Stop [2 times] Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n<http://www.mathworks.com./n/n>>> >> >> >> >> \\begin{align*}\n<file://begin%7balign*%7d/n>>> t = [0 \\quad1<file://quad1>] \\\\\n<file://n>>> y = [1 \\qquad0.666667<file://qquad0.666667>] \n>> \\end{align*}\n<file://end%7balign*%7d/n>>> " [3 times] Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n<http://www.mathworks.com./n/n>>> >> >> >> >> \\begin{align*}\n<file://begin%7balign*%7d/n>>> t = [0 \\quad1<file://quad1>] \\\\\n<file://n>>> y = [1 \\qquad0.666667<file://qquad0.666667>] \n>> \\end{align*}\n<file://end%7balign*%7d/n>>> " Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n\\begin<http://www.mathworks.com./n/n/begin>{align*}\nt= [0 \\quad1<file://quad1>] \\\\\ny<file://ny>= [1 \\qquad0.666667<file://qquad0.666667>] \n\\end{align*}\n" Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n\\begin<http://www.mathworks.com./n/n/begin>{align*}\nt= [0 \\quad1<file://quad1>] \\\\\ny<file://ny>= [1 \\qquad0.666667<file://qquad0.666667>] \n\\end{align*}\n" [5 times] Result: "\n< M A T L A B (R) >\nCopyright 1984-2012 The MathWorks, Inc.\nR2012a (7.14.0.739) 32-bit (glnx86)\nFebruary 9, 2012\n\n\nToget started, type one of these: helpwin, helpdesk, or demo.\nForproduct information, visit www.mathworks.com.\n\n\\begin<http://www.mathworks.com./n/n/begin>{align*}\nt= [0 \\quad1<file://quad1>] \\\\\ny<file://ny>= [1 \\qquad0.666667<file://qquad0.666667>] \n\\end{align*}\n" Result: (#1="" " < M A T L A B (R) >" " Copyright 1984-2012 The MathWorks, Inc." " R2012a (7.14.0.739) 32-bit (glnx86)" " February 9, 2012" #1# " " "To get started, type one of these: helpwin, helpdesk, or demo." "For product information, visit www.mathworks.com<http://www.mathworks.com>." " " "\\begin{align*}<file://begin%7balign*%7d>" "t = [0 \\quad1<file://quad1>] \\\\" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "\\end{align*}<file://end%7balign*%7d>" #1#) 1.2 Result cleaning (John) Result: ("\\begin{align*}<file://begin%7balign*%7d>" "t = [0 \\quad1<file://quad1>] \\\\" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "\\end{align*}<file://end%7balign*%7d>" "") Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" [2 times] Result: ("replace" "output" "latex") Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" Result: "\\begin{align*}\nt= [0 \\quad1] \\\\\ny= [1 \\qquad0.666667] \n\\end{align*}\n<file://begin%7balign*%7d/nt=%20%5b0%20/quad1%5d%20/ny=%20%5b1%20/qquad0.666667%5d%20/n/end%7balign*%7d/n>" 1.3 Result Matlab (Shell) Result: "f=@(t,y)[-t*y2];\n[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\nfprintf('t = [%g \\\\quad%g] \\\\\\\\\\n', t)\nfprintf('y = [%g \\\\qquad%g] \\n', y)\ndisp('\\end{align*}')\n" Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\n<file://n>>> fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n" [2 times] Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\n<file://n>>> fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n" [3 times] Result: ">> [t,y]=ode45(f,[0 1],1);\n>> t=[t(1),t(end)];\n>> y=[y(1),y(end)];\n>> disp('\\begin{align*}')\n\\begin{align*}\n>> fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\n<file://n>>> fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \n>> disp('\\end{align*}')\n\\end{align*}\n>> \n>> \n" Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" [5 times] Result: "[t,y]=ode45(f,[0 1],1);\nt=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: ("[t,y]=ode45(f,[0 1],1);" "t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}<file://begin%7balign*%7d>" "fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)" "t = [0 \\quad1<file://quad1>] \\\\" "fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "disp('\\end{align*}')" "\\end{align*}<file://end%7balign*%7d>" #1="" #1# #1#) 1.4 Result cleaning Result: ("t=[t(1),t(end)];" "y=[y(1),y(end)];" "disp('\\begin{align*}')" "\\begin{align*}<file://begin%7balign*%7d>" "fprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)" "t = [0 \\quad1<file://quad1>] \\\\" "fprintf('y = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)" "y = [1 \\qquad0.666667<file://qquad0.666667>] " "disp('\\end{align*}')" "\\end{align*}<file://end%7balign*%7d>" #1="" #1# #1#) Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Result: "t=[t(1),t(end)];\ny=[y(1),y(end)];\ndisp('\\begin{align*}')\n\\begin{align*}\nfprintf('t = [%g \\\\quad%g<file://quad%25g>] \\\\\\\\\\n<file://n>', t)\nt= [0 \\quad1<file://quad1>] \\\\\nfprintf('y<file://nfprintf('y> = [%g \\\\qquad%g<file://qquad%25g>] \\n<file://n>', y)\ny= [1 \\qquad0.666667<file://qquad0.666667>] \ndisp('\\end{align*}')\n\\end{align*}\n\n\n" Created: 2017-11-04 Sat 15:26 Validate<http://validator.w3.org/check?uri=referer> |
From: Uwe B. <ou...@ma...> - 2017-11-06 18:07:21
|
>>> "Eric" == Eric Ludlam <Eri...@ma...> writes: > It looks like an echoing feature is turned on, where input into ML is > echo'd back out again. There's a variable for describing what ML does > since the echo depends on platform or some-such. I think it's been 't' > for a long time. Hm thanks I checked and set (setq matlab-shell-echoes nil) It does not change #+begin_src matlab :results output latex :exports results :eval never-export f=@(t,y)[-t*y^2]; [t,y]=ode45(f,[0 1],1); t=[t(1),t(end)]; y=[y(1),y(end)]; disp('\begin{align*}') fprintf('t = [%g \\qquad %g \\quad %g] \\\\\n', t) fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) disp('\end{align*}') #+end_src Results in #+RESULTS: #+BEGIN_EXPORT latex >> f=@(t,y)[-t*y^2]; >> [t,y]=ode45(f,[0 1],1); >> t=[t(1),t(end)]; >> y=[y(1),y(end)]; >> disp('\begin{align*}') \begin{align*} >> fprintf('t = [%g \\qquad %g \\quad %g] \\\\\n', t) t = [0 \qquad 1 \quad >> fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) y = [1 \qquad 0.666667 \qquad >> disp('\end{align*}') \end{align*} #+END_EXPORT However I wrote a trivial cleaning function which just deletes the lines starting with >> and I obtain the following #+RESULTS: #+BEGIN_EXPORT latex \begin{align*} t = [0 \qquad 1 \quad >> fprintf('y = [%g \\qquad %g \\qquad %g] \n', y) y = [1 \qquad 0.666667 \qquad >> disp('\end{align*}') \end{align*} #+END_EXPORT Which is precisely what I want. I am not able to combine the cleaning function with the new org-babel-execute:matlab-shell Function because (matlab-shell-collect-command-output code))) Returns >> y=[0 5]\n>> Etc so everything is in one line (with \n) that results when inserted in newlines of course but running the cleaning function (flush-lines "^>>" nil nil t)) would delete everything For me this solution is ok but if somebody comes up with a better solution, please go ahead, the 2 new functions are (defun org-babel-execute:matlab-shell (body params) (interactive "P") (let* ((current-file (buffer-file-name)) (code (org-element-property :value (org-element-context))) (result-params (cdr (assoc :result-params params)))) (let ((results (matlab-shell-collect-command-output code))) (org-babel-result-cond result-params results)))) (defun clean-org-matlab-region-output () (interactive) (flush-lines "^>>" nil nil t)) But this is anyhow more relevant for org mode users. I brought up the issue on their mailing list as well but there was not much interest. Uwe |