-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmg_writeSharedVariables.m
More file actions
56 lines (49 loc) · 1.43 KB
/
Copy pathmg_writeSharedVariables.m
File metadata and controls
56 lines (49 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%=== GraderPlus ===
%
%Library for advanced testing in MATLAB® Grader
%Created by David Kosfelder
%for the Process Dynamics and Operations Group at TU Dortmund
%
%Contact: david.kosfelder@tu-dortmund.de
%
%
%
%=== Function Summary ===
%
%Function Name: mg_writeSharedVariables
%
%Description:
% This function allows storing variables created in a test for later use
% in following tests.
%
%Inputs:
% varargin (strings / char arrays)
% Names of variables that shall be stored
%
% Outputs:
% success (bool)
% Indicates if the storing operation was successful
function [success] = mg_writeSharedVariables(varargin)
success = true();
try
%varargin to formatted string
vars = "";
for varName = varargin
vars = vars + ",'" + varName{:} + "'";
end
%add append when file exists to prevent override
append = "";
if isfile('mg_sharedvarstorage.mat')
append = ",'-append'";
end
% Exclude grader vars
exclude = ",'-regexp','^(?!(currentFigureHandles|previousFigureHandles|referenceVariables|seed|show)$).'";
%evaluate function in caller
fncCall = "save('mg_sharedvarstorage.mat' " + vars + append + exclude + ");";
evalin('caller', fncCall);
catch ME
%error handling
disp(ME);
success = false();
end
end