time | Calls | line |
|---|
| | 1 | function data = makeStructure(names, values, areNamesUnique)
|
| | 2 | % Create a structure from names and values cell arrays. Ensure the names
|
| | 3 | % are unique.
|
| | 4 | % Syntax
|
| | 5 | %
|
| | 6 | % data = makeStructure(names, values, areNamesUnique)
|
| | 7 | %
|
| | 8 | % Description
|
| | 9 | %
|
| | 10 | % data = makeStructure(names, values, areNamesUnique) creates a structure from names and values cell arrays
|
| | 11 | %
|
| | 12 | %
|
| | 13 | % Input Arguments
|
| | 14 | %
|
| | 15 | % names - cell array
|
| | 16 | % values - cell array
|
| | 17 | % areNamesUnique - logical (true/false)
|
| | 18 | %
|
| | 19 | % Output Arguments
|
| | 20 | %
|
| | 21 | % data - output structure containing unique and valid field names
|
| | 22 | %
|
| | 23 | % Example
|
| | 24 | %
|
| | 25 | % names = {'x_0', 'x'};
|
| | 26 | % values = {'Hello', 24};
|
| | 27 | % areNamesUnique = true;
|
| | 28 | % matlab.internal.json.makeStructure(names, values, areNamesUnique)
|
| | 29 | %
|
| | 30 | % This function is internal and is subject to change in the future.
|
| | 31 |
|
| | 32 | % Copyright 2015-2019 The MathWorks, Inc.
|
| | 33 | % CONFIDENTIAL AND CONTAINING PROPRIETARY TRADE SECRETS
|
| | 34 | % The source code contained in this listing contains proprietary and
|
| | 35 | % confidential trade secrets of The MathWorks, Inc. The use, modification,
|
| | 36 | % or development of derivative work based on the code or ideas obtained
|
| | 37 | % from the code is prohibited without the express written permission of The
|
| | 38 | % MathWorks, Inc. The disclosure of this code to any party not authorized
|
| | 39 | % by The MathWorks, Inc. is strictly forbidden.
|
| | 40 |
|
< 0.001 | 1 | 41 | if ~(areNamesUnique)
|
| | 42 | names = matlab.lang.makeUniqueStrings(names, 1:numel(names), namelengthmax);
|
| | 43 |
|
| 1 | 44 | end
|
0.010 | 1 | 45 | data = cell2struct(values, names, 1);
|
| 1 | 46 | if isempty(data)
|
| | 47 | data = struct;
|
| 1 | 48 | end
|
< 0.001 | 1 | 49 | end
|
Other subfunctions in this file are not included in this listing.