{"id":1129,"date":"2017-11-02T13:01:38","date_gmt":"2017-11-02T17:01:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/developer\/?p=1129"},"modified":"2017-11-02T14:44:19","modified_gmt":"2017-11-02T18:44:19","slug":"matlab-drive-and-github","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/developer\/2017\/11\/02\/matlab-drive-and-github\/","title":{"rendered":"Driving Productivity &#8230; Without Losing Control"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p><i>Hi all, today I'd like to turn the time over to Matt Tearle from our Training Services group who has a great story to share about how two different MATLAB code workflows \"just work\" together to make an even more powerful flow. We'd all do well to learn from Matt, he is passionate about MATLAB and is constantly finding new ways to leverage its power. Take it away Matt!<\/i><\/p><p><b>The goal: develop anywhere<\/b><\/p><p>Don't you hate it when you're trying to figure out why your algorithm isn't working but you have to attend a meeting, or pick up your kids, or get to a dentist appointment? But then as you're sitting there waiting for the dentist to examine your X-rays, you realize that you forgot to rescale <tt>z<\/tt> before interpolating. It's a simple fix. You could do it right now, in a few seconds... if only you had (a) MATLAB and (b) your files.<\/p><p>MATLAB Online and MATLAB Mobile give a solution to (a), but what about (b)?<\/p><p>This kind of scenario is why I love MATLAB Drive. It's a cloud storage system for your files - similar to Dropbox or Google Drive - but with the important added benefit that it integrates seamlessly with MATLAB Online\/MATLAB Mobile. In fact, your file system in MATLAB Online <b>is<\/b> MATLAB Drive. This means you don't have to mess about getting your files from your chosen cloud storage system to MATLAB Online.<\/p><p>I have installed the MATLAB Drive client on all the computers I use regularly for MATLAB. If I happen to be using MATLAB on another machine, I can access my MATLAB Drive files <a href=\"https:\/\/drive.matlab.com\/login\">online<\/a>. And if I'm on a machine without MATLAB, or I'm using a mobile device, I can use MATLAB Online or MATLAB Mobile. So whichever way I'm doing my MATLAB, I have my files!<\/p><!--\/introduction--><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/y2017_MLDrive.png\" alt=\"\"> <\/p><p>MATLAB Drive solves problem (b) and its integration with MATLAB Online and MATLAB Mobile solves both (a) and (b). This, then, gives me the ability to develop from anyway - work, home, the bus, the dentist, my kids' ballet rehearsal (seriously, those things last forever). I now routinely keep most of my personal side-projects in my Drive folder.<\/p><p><b>A potential problem<\/b><\/p><p>But what if I want to do this \"anywhere-development\" on files that are in my source control folder? For me, this usually means my File Exchange submissions, which I have on GitHub. These files live in a \"sandbox\" folder on my local drive. I use the built-in MATLAB Git integration to keep this sandbox folder under source control.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/y2017_separateSandbox.png\" alt=\"\"> <\/p><p>I can work on files locally, then integrate to GitHub. But how do I get access to those files from anywhere? That is, how do I get source control and the convenience of MATLAB Drive?<\/p><p><b>The solution: keep it simple<\/b><\/p><p>At first this seemed like it could be complicated. Do I need a source control client on every device? That doesn't seem very convenient. But, generally, I have one main computer that I use to manage the source control; I just need access to files so that I can keep tinkering with them from various locations. In that case, the solution is remarkably simple: keep my local repositories inside my Drive folder.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/y2017_moveSandbox.png\" alt=\"\"> <\/p><p>That is, my sandbox folder is just one of the folders in my Drive folder. Now I can work on my sandbox files from anywhere and any changes I make are replicated through my Drive client. If I want to work on a file at work or at home, the Drive Connector on my work laptop or home desktop synchronizes my changes. If I want to work on a mobile device, I can connect to MATLAB Online and I'm automatically working on my MATLAB Drive files.<\/p><p>The next time I get back to my work laptop, my files are up to date. I can keep working or check them in. Easy.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/y2017_solution.png\" alt=\"\"> <\/p><p>Making the change was easy, too. I just created a new local sandbox inside my Drive folder, sourced from the existing GitHub repo.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/developer\/files\/y2017_createRepo.png\" alt=\"\"> <\/p><p>This pulled the files from GitHub into my new Drive\/sandbox folder. Then I just deleted my old (non-Drive) sandbox folder. That's one nice aspect of source control in MATLAB: it's easy to make local repos. Having made the change, it's now easy to keep everything new there.<\/p><p><b>Ready to drive? Go ahead: take control!<\/b><\/p><p>Have you avoided integrating MATLAB Drive into your development workflow because you didn't think it would work with source control? If so, give it a try! I hope you will be as pleasantly surprised as I was at how painless it is. Or are you already using MATLAB Drive? If so, please share your experiences and tips in the <a href=\"https:\/\/blogs.mathworks.com\/developer\/2017\/11\/02\/matlab-drive-and-github\/#respond\">comments<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_a7b8a2d67d244a0d900fa730b221bd0f() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='a7b8a2d67d244a0d900fa730b221bd0f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a7b8a2d67d244a0d900fa730b221bd0f';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_a7b8a2d67d244a0d900fa730b221bd0f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2017b<br><\/p><\/div><!--\r\na7b8a2d67d244a0d900fa730b221bd0f ##### SOURCE BEGIN #####\r\n%%\r\n%\r\n% _Hi all, today I'd like to turn the time over to Matt Tearle from our\r\n% Training Services group who has a great story to share about how two\r\n% different MATLAB code workflows \"just work\" together to make an even more\r\n% powerful flow. We'd all do well to learn from Matt, he is passionate\r\n% about MATLAB and is constantly finding new ways to leverage its power.\r\n% Take it away Matt!_\r\n% \r\n% *The goal: develop anywhere*\r\n%\r\n% Don't you hate it when you're trying to figure out why your algorithm\r\n% isn't working but you have to attend a meeting, or pick up your kids, or\r\n% get to a dentist appointment? But then as you're sitting there waiting\r\n% for the dentist to examine your X-rays, you realize that you forgot to\r\n% rescale |z| before interpolating. It's a simple fix. You could do it\r\n% right now, in a few seconds... if only you had (a) MATLAB and (b) your\r\n% files.\r\n% \r\n% MATLAB Online and MATLAB Mobile give a solution to (a), but what about\r\n% (b)?\r\n% \r\n% This kind of scenario is why I love MATLAB Drive. It's a cloud storage\r\n% system for your files - similar to Dropbox or Google Drive - but with\r\n% the important added benefit that it integrates seamlessly with MATLAB\r\n% Online\/MATLAB Mobile. In fact, your file system in MATLAB Online *is*\r\n% MATLAB Drive. This means you don't have to mess about getting your files\r\n% from your chosen cloud storage system to MATLAB Online.\r\n%\r\n% I have installed the MATLAB Drive client on all the computers I use\r\n% regularly for MATLAB. If I happen to be using MATLAB on another machine,\r\n% I can access my MATLAB Drive files <https:\/\/drive.matlab.com\/login\r\n% online>. And if I'm on a machine without MATLAB, or I'm using a mobile\r\n% device, I can use MATLAB Online or MATLAB Mobile. So whichever way I'm\r\n% doing my MATLAB, I have my files!\r\n \r\n%%\r\n% <<y2017_MLDrive.png>>\r\n\r\n%% \r\n% MATLAB Drive solves problem (b) and its integration with MATLAB\r\n% Online and MATLAB Mobile solves both (a) and (b). This, then, gives me\r\n% the ability to develop from anyway - work, home, the bus, the dentist,\r\n% my kids' ballet rehearsal (seriously, those things last forever). I now\r\n% routinely keep most of my personal side-projects in my Drive folder.\r\n\r\n%%\r\n% *A potential problem*\r\n%\r\n% But what if I want to do this \"anywhere-development\" on files that are in\r\n% my source control folder? For me, this usually means my File Exchange\r\n% submissions, which I have on GitHub. These files live in a \"sandbox\"\r\n% folder on my local drive. I use the built-in MATLAB Git integration to\r\n% keep this sandbox folder under source control.\r\n\r\n%% \r\n% <<y2017_separateSandbox.png>>\r\n\r\n%%\r\n% I can work on files locally, then integrate to GitHub. But how do I get\r\n% access to those files from anywhere? That is, how do I get source control\r\n% and the convenience of MATLAB Drive?\r\n\r\n%%\r\n% *The solution: keep it simple*\r\n%\r\n% At first this seemed like it could be complicated. Do I need a source\r\n% control client on every device? That doesn't seem very convenient. But,\r\n% generally, I have one main computer that I use to manage the source\r\n% control; I just need access to files so that I can keep tinkering with\r\n% them from various locations. In that case, the solution is remarkably\r\n% simple: keep my local repositories inside my Drive folder.\r\n\r\n%%  \r\n% <<y2017_moveSandbox.png>>\r\n\r\n%%\r\n% That is, my sandbox folder is just one of the folders in my Drive folder.\r\n% Now I can work on my sandbox files from anywhere and any changes I make\r\n% are replicated through my Drive client. If I want to work on a file at\r\n% work or at home, the Drive Connector on my work laptop or home desktop\r\n% synchronizes my changes. If I want to work on a mobile device, I can\r\n% connect to MATLAB Online and I'm automatically working on my MATLAB Drive\r\n% files.\r\n% \r\n% The next time I get back to my work laptop, my files are up to date. I\r\n% can keep working or check them in. Easy.\r\n \r\n%%\r\n% <<y2017_solution.png>>\r\n\r\n%% \r\n% Making the change was easy, too. I just created a new local sandbox\r\n% inside my Drive folder, sourced from the existing GitHub repo.\r\n\r\n%%  \r\n% <<y2017_createRepo.png>>\r\n\r\n%%\r\n% This pulled the files from GitHub into my new Drive\/sandbox folder. Then\r\n% I just deleted my old (non-Drive) sandbox folder. That's one nice aspect\r\n% of source control in MATLAB: it's easy to make local repos. Having made\r\n% the change, it's now easy to keep everything new there.\r\n\r\n%% \r\n% *Ready to drive? Go ahead: take control!*\r\n%\r\n% Have you avoided integrating MATLAB Drive into your development workflow\r\n% because you didn't think it would work with source control? If so, give\r\n% it a try! I hope you will be as pleasantly surprised as I was at how\r\n% painless it is. Or are you already using MATLAB Drive? If so, please\r\n% share your experiences and tips in the\r\n% <https:\/\/blogs.mathworks.com\/developer\/2017\/11\/02\/matlab-drive-and-github\/#respond\r\n% comments>.\r\n\r\n##### SOURCE END ##### a7b8a2d67d244a0d900fa730b221bd0f\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/developer\/files\/y2017_solution.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p><i>Hi all, today I'd like to turn the time over to Matt Tearle from our Training Services group who has a great story to share about how two different MATLAB code workflows \"just work\" together to make an even more powerful flow. We'd all do well to learn from Matt, he is passionate about MATLAB and is constantly finding new ways to leverage its power. Take it away Matt!<\/i>... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/developer\/2017\/11\/02\/matlab-drive-and-github\/\">read more >><\/a><\/p>","protected":false},"author":90,"featured_media":1135,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,20],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/1129"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/comments?post=1129"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/1129\/revisions"}],"predecessor-version":[{"id":1144,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/posts\/1129\/revisions\/1144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/media\/1135"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/media?parent=1129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/categories?post=1129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/developer\/wp-json\/wp\/v2\/tags?post=1129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}