Practical Advice for People on the Leading Edge

Open science and reusable research with MATLAB Online and GitHub

You’ve written a research paper and you have some MATLAB code that supports it. How do you disseminate this to make it accessible to as many people as possible? Here’s the new workflow.
  • Step 1: Put your MATLAB code onto GitHub
  • Step 2: From the repo, create a link that lets us open up directly in MATLAB Online and share it anywhere. One way to do this is to add a badge to the repo. Like this one:
That’s it! Now, if someone wants to run or modify your code, they just click on ‘Open in MATLAB Online’ and start interacting with your work.
In many cases, this also works when they don’t have a MATLAB license!
Mic Drop
I wanted to end this article there. This is a development that I find so exciting that I’ve been begging to publish something about it ever since I first learned of it. Some of my friends around here, however, suggested that maybe I add a little more detail. So here goes….

Put your MATLAB and Simulink-based research code on GitHub

For many years now, I have been promoting better practices in research software along with colleagues from the Research Software Engineering community. A huge amount of modern research critically relies on computational software but Is Your Research Software Correct? is a question I like to ask my research colleagues. A large part of my career has been devoted to helping the answer to that question be ‘yes’ for as many people as possible.
In ‘Is your Research Software Correct?, one of the earliest pieces of advice I give to researchers is ‘use version control’….always! I prefer and recommend git and GitHub but other version control systems are fine if you insist. In this new workflow, however, MathWorks have initially targeted GitHub due to its massive popularity.
Once your research code is on GitHub, it’s ‘out there’ and available for other people to use. It’s an extremely important first step in the practice of open science and, once you’ve made it, you are free to add on all kinds of things to level up your game. From simple moves such as a well-written Readme file and a demo of your code in a Live Script right up to unit testing, continuous integration and getting a DOI.

Add an ‘Open in MATLAB Online’ badge to the repo.

MATLAB Online is a browser-based version of MATLAB running on the cloud and was used by over 1.5 million people last year. Read more about it here or, better yet, go and have a play with it at )
GitHub helps make your code available. MATLAB Online helps makes it easier to use. Of course, your users are free to download your code from GitHub or use command line git to clone the repository. They can then make use of their desktop version of MATLAB to work with your research.
Adding an ‘Open in MATLAB Online badge makes it even easier for those interested to play with your research. All you need to do is form the link based on your repo’s URL. For example:
In the above link we’ve also encoded the fact that we want the file SolarPanelEstimator.mlx to be loaded when we enter MATLAB Online.
When someone clicks on the above link, MATLAB Online will open, the repo will be cloned to their MATLAB drive and the requested file will be opened. The gif below shows what this looks like in practice.
Notice that the Live Script that was opened was a simple application that was made using Live Controls. The code behind it, for those who want it, is available to view and edit with a single click.

Any public repo, any time, one-click clone

What I like about this new workflow is that the owner of the GitHub repo doesn’t need to do anything for me to be able to make use of their code in this way. I could find any GitHub repo containing MATLAB code, form the link and make it available to my readers, students or collaborators.
At the time of writing, this great repo from Rob Campbell doesn’t have an ‘Open in MATLAB Online’ badge:
Following the instructions in the documentation, I form the URL
and we are done. Alternatively, you can simply feed the GitHub repo to this webpage and it will do it for you automatically.
Of course, as the owner of a repo, I could make it easier for my users to open my code by adding some MarkDown to the ReadMe file.
[![Open in MATLAB Online](](
This produces a badge that looks like this

No MATLAB license? No problem.

A huge number of universities and research institutions have MATLAB licenses but what if your collaborators do not? How do they run, edit and generally play around with your code? The answer is, they just click on the link and get on with it.
All they need is a free MathWorks Account and they can make use of MATLAB Online (basic). There are limitations, to be sure (details here), but a lot of things are supported and it’s useful for a large number of workflows. It all Just Works!

Add ‘Open in MATLAB Online to your repo now

If you have some MATLAB code and want to make it more accessible to the world, why not add the badge to your repo now?
  • print


댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.