How to include custom libraries in MATLAB Grader?

How do I include my own libraries in MATLAB Grader? Adding all the files one by one or adding a selection of files is not a good solution for me.

 Accepted Answer

One way to upload custom libraries containing folders/subfolders is to zip them into chunks of sizes up to 5MB and then upload these zips. The only limitation is that the upload size is capped at 5MB, but you can upload an unlimited number of times without any restriction on the total upload size. You can then programmatically unzip the library. For example, if the library "MyLib" has been zipped into two zips with names "MyLib1.zip" and "MyLib2.zip" then it can be unzipped in a folder called "MyLib" and added to the MATLAB's path using the following set of commands:
if exist('MyLib', 'dir') ~= 7
unzip('MyLib1.zip', 'MyLib');
unzip('MyLib2.zip', 'MyLib');
addpath(genpath('MyLib'));
end
There are some additional points that you should be aware of:
1) Even though you can upload unlimited times, MATLAB Grader has a 60 second execution time limit. It starts when pressing Run or Submit, and continuous until the results are displayed. Thus the code containing the unzipping command plus the functionality that you want to implement needs to be executable in under 60 seconds. When creating the zip file, it is suggested to leave out files that are not needed in MATLAB Grader. This might include documentation, help files, toolbox install files, etc.
2) Each time you click on Run/Submit you are connected to a brand new instance of MATLAB. Nothing is preserved from the previous run.
3) On each problem, you have to upload again the zipped files and you need to have the unzipping process first on each script.
4) MATLAB Grader does not allow interactive processes and it is intended for unattended use only. It is just a webpage that sends all the code to a server which then executes it and returns the results back to the webpage. Thus if the library requires interaction from you then MATLAB Grader cannot support it. In the case the library contains MEX files then it should be tested first on MATLAB Online, if it works there then it should also work on MATLAB Grader.
5) It is important to determine which problems are a good fit for MATLAB Grader. Use the criteria explained above to determine when MATLAB Grader is appropriate, and when it would be better to use MATLAB or MATLAB Online instead.

More Answers (0)

Categories

Products

Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!