Guy on Simulink Material on GitHub and MATLAB Online
Did you notice the recent blog post Open science and reusable research with MATLAB Online and GitHub by my colleague Mike Croucher on The MATLAB Blog?
I decided to try adopting this new feature to open GitHub repositories directly in MATLAB Online. That way, you will now be able to open my blog posts and related files in MATLAB Online in one click. As described by Mike, this will work even if you don't have a MATLAB license, all you need is a free MathWorks account.
Let's see how this works.
A GitHub repository for Guy on Simulink material
To make it easier for you to reproduce what I am covering on this blog, I created a GitHub repository: github.com/simulink/blog
For each post, I will add a folder in the repository with the MATLAB live script I used to create the post, along with all MATLAB scripts, functions, Simulink models, and other files I used while writing the post. In the above screenshot, you can see the folder for my previous post on debugging custom C/C++ code. More folders will be added as new posts gets published.
In case anyone is wondering, I use the Publishing tool for MATLAB® live script to WordPress to publish posts on this blog.
Opening Blog Posts in MATLAB Online
Did you notice the Open in MATLAB Online badge at the end of my last blog post?
If you click on the link the following will happen:
- MATLAB Online will open and ask you to log in using your MathWorks account
- In MATLAB Online, a dialog will appear to offer you to clone my GitHub repository in your MATLAB Drive
- The MATLAB live script will open in the MATLAB Editor, ready for you to read, execute, and modify.
This should make it easy for you to try and modify my examples directly in your web browser.
In case you would like to do the same with your GitHub repositories, the way to create the URL to open any GitHub repository in MATLAB Online is documented here: Open in MATLAB Online from GitHub.
A Simulink Example
It would be sad to end this post without at least opening and simulating a Simulink model. Here is a simple mass-spring-damper model:
mdl = 'ex_modeling_simple_system';
open_system(mdl);
Here is what the model looks like in MATLAB Online:
We can simulate it:
in = Simulink.SimulationInput(mdl);
out = sim(in);
plot(out)
Now it's your turn
Start right now and open this blog post in MATLAB Online:
I hope you will like this new way to easily access all the files needed to reproduce my blog posts.
- Category:
- Community,
- What's new?
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.