-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveMatrix.m
37 lines (30 loc) · 909 Bytes
/
saveMatrix.m
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
function filename = saveMatrix(matrix, varargin)
% SAVEMATRIX Save a matrix to the current directory.
%
% SAVEMATRIX(MATRIX) generates a filename and saves the matrix MATRIX to the associated file.
%
% SAVEMATRIX(MATRIX, FILENAME) saves the matrix MATRIX to the file FILENAME.MAT
%
% Input:
% matrix - Matrix to be saved
% filename - (Optional) String containing filename
%
% Output:
% filename - Filename
%
% Author: Christian Schwarzer - SSC EPFL
% CreationDate: 25.11.2002 LastModified: 20.01.2003
switch nargin
case 1
filename = datestr(now,'yyyymmddTHHMMSS');
if(isstruct(matrix))
filename = strcat(filename, 'struct');
else
filename = strcat(filename, 'mat');
end
case 2
filename = varargin{1};
otherwise
error('Wrong number of arguments. Type: help saveMatrix')
end
save(filename, 'matrix');