Skip to content
Snippets Groups Projects
Commit 2b85f2b4 authored by William Lövfors's avatar William Lövfors
Browse files

Added a new function to concatenate simulations

parent eebd0453
No related branches found
No related tags found
No related merge requests found
function [S] = CatSims(structs)
%Cat Concatenates multiple structs. If concatenating simulation structs from IQM, you probably want to use CatSim instead.
S = structs(1);
for i = 2:length(structs)
fields = fieldnames(S);
for k = 1:numel(fields)
aField = fields{k}; % EDIT: changed to {}
if strcmp(aField,'time') % If field is a horizontal 1D array
S.(aField) = horzcat(S.(aField), structs(i).(aField));
elseif contains(aField, 'values')%if field is a vertical 1D array
S.(aField) = vertcat(S.(aField), structs(i).(aField));
end
end
end
end
......@@ -18,5 +18,14 @@ else
end
includefolder = fileparts(which('mexmathaddon.h'));
% do compilation
try
eval(sprintf('mex -O -I''%s'' %s.c ''%s'';',includefolder,filename,libpath));
catch err
if contains(err.message, 'is not a MEX file')
disp(getReport(err))
disp('When running on linux, this error sometimes occurs, but the model still works.')
else
rethrow(err)
end
end
function [] = mexcompileSBPD(filename)
% mexcompileSBPD: Compiles an SBmodel that has been converted to a mexfile.h
% mexcompileSBPD: Compiles an SBmodel that has been converted to a mexfile.h
% and mexfile.c and links it with the CVODE integrator from the SUNDIALS
% suite (http://www.llnl.gov/CASC/sundials/).
%
% suite (http://www.llnl.gov/CASC/sundials/).
%
% USAGE:
% ======
% [] = mexcompileSBPD(mexfile)
%
% mexfile: Basename of the model files (mexfile.c and mexfile.h)
% mexfile: Basename of the model files (mexfile.c and mexfile.h)
% Information:
% ============
% Copyright (C) 2005-2013 Henning Schmidt, henning@sbtoolbox2.org
......@@ -17,15 +17,15 @@ function [] = mexcompileSBPD(filename)
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
% USA.
if ~isunix,
......@@ -35,5 +35,15 @@ else
end
includefolder = fileparts(which('mexmathaddon.h'));
% do compilation
eval(sprintf('mex -O -I''%s'' %s.c ''%s'';',includefolder,filename,libpath));
try
eval(sprintf('mex -O -I''%s'' %s.c ''%s'';',includefolder,filename,libpath));
catch err
if contains(err.message, 'is not a MEX file')
disp(getReport(err))
disp('When running on linux, this error sometimes occurs, but the model still works.')
else
rethrow(err)
end
end
end
\ No newline at end of file
function S = StructFieldCat(S, T, dim)
%STRUCTFIELDCAT: concatenate two structs.
if nargin<3 || isempty(dim)
dim=1;
end
......
function [s] = StructsFieldCat(structs, dim)
%STRUCTSFIELDCAT Summary of this function goes here
% Detailed explanation goes here
%STRUCTSFIELDCAT Concatenates multiple structs. If concatenating simulation structs from IQM, you probably want to use CatSim instead.
if nargin<2 || isempty(dim)
dim=1;
end
......@@ -10,3 +9,5 @@ for i = 2:length(structs)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment