MATLAB Projects
Sean‘s pick this week is MATLAB Project File by Dmitry Ratner and the new Projects functionality in base MATLAB added to R2019a. This was previously Simulink Projects but Simulink is no longer required.
Have you ever wanted to work on a project and when starting for the day, or had a new team member start on the project, have everything configured for you? Well now you can leave behind those addpath(genpath(pwd)) and those instructions like “run this script before starting” or the effort to manually choose which files export when sharing with someone else!
Dmitry’s File Exchange submission provides a means for configuring the path, shortcuts, and a startup script and works in older versions of MATLAB. Projects in base MATLAB also do this but go much further by allowing export capabilities, shut down files, upgrade advisors, categories for different files, graphical dependency and product analysis, integration with source control and more.
Here I will describe how to create a project from an existing set of files and configure it. I will use the “Pick of the Week” Folder where I keep all of the blog entries and utilities to publish them.
First, create a new project. I usually do this by going from an existing folder to a project (even if the existing folder is under source control).
Give it a descriptive name and then set it up. Set up will ask you which folders to add to the path.
You can then specify anything to run when starting or shutting down the project. I don’t need that here.
Next you can create custom labels or use the existing ones to label files in the project. A filter can then be applied to show just those files.
If you’d like to see dependencies in the project, you can right click on a file to view it’s dependencies as a graph, or the files impacted by it if you want to change it. This will also point out project dependencies and potential missing files required for your code to run.
You can run checks against the project, upgrade it at once (more important for Simulink workflows), and manage source control all from within the project toolstrips, and have custom tasks or shortcuts.
Additionally, you can replace anywhere that needs to find the location of a file using mfilename('fullpath') with the RootFolder property of currentProject.
prj = currentProject
prj = Project with properties: Name: "potw" SourceControlIntegration: "Git" RepositoryLocation: "http://insidelabs-git.mathworks.com/sdewolsk/potw.git" SourceControlMessages: [1×3 string] ReadOnly: 0 TopLevel: 1 Dependencies: [1×1 digraph] Categories: [1×1 matlab.project.Category] Files: [1×4604 matlab.project.ProjectFile] Shortcuts: [1×0 matlab.project.Shortcut] ProjectPath: [1×19 matlab.project.PathFolder] ProjectReferences: [1×0 matlab.project.ProjectReference] StartupFiles: [1×0 string] ShutdownFiles: [1×0 string] Description: "" RootFolder: "C:\Documents\MATLAB\potw" ProjectStartupFolder: "C:\Documents\MATLAB\potw\MatlabProject" SimulinkCacheFolder: "" SimulinkCodeGenFolder: ""
I hope you’re as excited about Projects in MATLAB as I am. I’ve been using them since the prerelease became available to us and it has made my day to day project work much easier.
Comments
Give it MATLAB projects a try and let us know what you think here or leave a comment for Dmitry.
Published with MATLAB® R2019a
- Category:
- Picks
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.