{"id":6,"date":"2007-06-25T07:30:07","date_gmt":"2007-06-25T12:30:07","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2007\/06\/25\/creating-an-m-file-from-selections-in-the-command-history\/"},"modified":"2007-06-25T07:30:36","modified_gmt":"2007-06-25T12:30:36","slug":"creating-an-m-file-from-selections-in-the-command-history","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2007\/06\/25\/creating-an-m-file-from-selections-in-the-command-history\/","title":{"rendered":"Creating an M-file from selections in the Command History"},"content":{"rendered":"<p>Getting started writing an M-file can be difficult sometimes.  It&#8217;s akin to writing a term paper.  That first bit is always difficult to write.<\/p>\n<p>Often when I am writing M code, I start in the Command Window, rather than the Editor, to help get the initial part of the code working in a more interactive fashion.  In the Command Window I can play around with the code until I get it right.  I then go back later and put the code into a function in the Editor.  But instead of copying code from the Command Window or the Command History and pasting it in the Editor, I use the Command History context menu: &#8220;Create M-File&#8221;.  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/community\/..\/images\/desktop\/history_saveMFile.jpg\" alt=\"History Create M file\" \/><\/p>\n<p>The &#8220;Create M-File&#8221; context menu item opens an Editor window and pre-populates the new file with any selected commands from the Command History.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/community\/..\/images\/desktop\/editor_history.jpg\"><img decoding=\"async\" id=\"image25\" src=\"https:\/\/blogs.mathworks.com\/community\/..\/images\/desktop\/editor_history_small.jpg\" alt=\"editor_history.jpg\" \/><\/a><\/p>\n<p>The next time you find that you are working in this mode and you are ready to commit your code to a file, try using the &#8220;Create M-file&#8221; context menuitem from the Command History.   This is easier and quicker than using copy\/paste or re-typing the code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting started writing an M-file can be difficult sometimes.  It&#8217;s akin to writing a term paper.  That first bit is always difficult to write.<br \/>\nOften when I am writing M code, I start in the&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2007\/06\/25\/creating-an-m-file-from-selections-in-the-command-history\/\">read more >><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}