File Exchange Pick of the Week

Our best user submissions

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

MATLAB Projects 2

Posted by Sean de Wolski,

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.

Get the MATLAB code

Published with MATLAB® R2019a

Note

Comments are closed.

2 CommentsOldest to Newest

Kathleen Edwards replied on : 1 of 2
Thanks! I would love to see an instructional video on this too, for example person #2 receives a Matlab project from person #1 and starts to run it, or person #1 takes a messy code sandbox and cleans it up into a project. I don't use Simulink so a Matlab based video would be more helpful to me.