Commit 837c9f0c authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

overloading the "ones" function for quantity.Discrete

parent cdcdc8f8
......@@ -1144,6 +1144,7 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
p.addParameter('titleWithIndex', true');
p.addParameter('hold', false);
p.addParameter('export', false);
p.addParameter('currentFigure', false);
p.addParameter('exportOptions', ...
{'height', [num2str(0.25*size(obj, 1)), '\textwidth'], ...
'width', '0.8\textwidth', 'externalData', false, ...
......@@ -1159,7 +1160,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
fig = p.Results.fig;
dock = p.Results.dock;
for figureIdx = 1:size(obj, 3)
if isempty(p.Results.fig)
if p.Results.currentFigure
h = gcf;
elseif isempty(p.Results.fig)
h = figure();
elseif p.Results.fig == 0
h = gcf;
......@@ -1183,7 +1186,9 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
for rowIdx = subplotRowIdx
for columnIdx = subpotColumnIdx
subplot(size(obj, 1), size(obj, 2), i(rowIdx, columnIdx));
if ~p.Results.currentFigure
subplot(size(obj, 1), size(obj, 2), i(rowIdx, columnIdx));
end
if p.Results.hold
hold on;
else
......@@ -2321,6 +2326,30 @@ classdef (InferiorClasses = {?quantity.Symbolic}) Discrete ...
%%
methods (Static)
function P = ones(valueSize, domain, varargin)
%ONES initializes an ones-quantity.Discrete object
% P = ones(VALUESIZE, DOMAIN) creates a matrix of size
% VALUESIZE on the DOMAIN with ones as entries.
myParser = misc.Parser();
myParser.addParameter('gridName', []);
myParser.parse(varargin{:});
if ~isa(domain, 'quantity.Domain')
% if the input parameter DOMAIN is not a quantity.Domain
% object. It is assumed that it is a grid.
domain = quantity.Domain.gridCells2domain(...
domain, myParser.Results.gridName);
end
if any( valueSize == 0)
P = quantity.Discrete.empty(valueSize);
else
O = ones([domain.gridLength, valueSize(:)']);
P = quantity.Discrete(O, 'size', valueSize, 'domain', domain, varargin{:});
end
end
function P = zeros(valueSize, domain, varargin)
%ZEROS initializes an zero quantity.Discrete object
% P = zeros(VALUESIZE, DOMAIN) creates a matrix of size
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment