Home > cellorganizer > utilities > plotmodelsparam.m

plotmodelsparam

PURPOSE ^

PLOTMODELSPARAM plots the independent variable, x, against the models struct component, modelVar.

SYNOPSIS ^

function [ h, x, y ] = plotmodelsparam( models, x, modelvar, plotfunc )

DESCRIPTION ^

PLOTMODELSPARAM plots the independent variable, x, against the models struct component, modelVar.
The model parameter value gets concatonated along the first non-singleton
dimension

Inputs:
 models = a cell array of models to compare
 x = the independent variable
 modelvar = the field of the model to compare
plotfunc = (optional) function handle for plotting the parameters

Outputs:
 h = plot handle
 x = array of x values
 y = array of y values

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ h, x, y ] = plotmodelsparam( models, x, modelvar, plotfunc )
0002 %PLOTMODELSPARAM plots the independent variable, x, against the models struct component, modelVar.
0003 %The model parameter value gets concatonated along the first non-singleton
0004 %dimension
0005 %
0006 %Inputs:
0007 % models = a cell array of models to compare
0008 % x = the independent variable
0009 % modelvar = the field of the model to compare
0010 %plotfunc = (optional) function handle for plotting the parameters
0011 %
0012 %Outputs:
0013 % h = plot handle
0014 % x = array of x values
0015 % y = array of y values
0016 
0017 %Author: Greg Johnson 16/5/2013
0018 %Edited: D. Sullivan 9/27/13 - documentation
0019 %
0020 % Copyright (C) 2013 Murphy Lab
0021 % Carnegie Mellon University
0022 %
0023 % This program is free software; you can redistribute it and/or modify
0024 % it under the terms of the GNU General Public License as published
0025 % by the Free Software Foundation; either version 2 of the License,
0026 % or (at your option) any later version.
0027 %
0028 % This program is distributed in the hope that it will be useful, but
0029 % WITHOUT ANY WARRANTY; without even the implied warranty of
0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0031 % General Public License for more details.
0032 %
0033 % You should have received a copy of the GNU General Public License
0034 % along with this program; if not, write to the Free Software
0035 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0036 % 02110-1301, USA.
0037 %
0038 % For additional information visit http://murphylab.web.cmu.edu or
0039 % send email to murphy@cmu.edu
0040 
0041 if ~exist('x', 'var')
0042     x = ones(1, length(models));
0043 end
0044 
0045 if iscell(models)
0046     models = [models{:}];
0047 end
0048 
0049 tokens = regexp(modelvar, '\.', 'split');
0050 
0051 %Get the data from each model
0052 for i = 1:length(models)
0053     model = models(i);
0054     for j = 1:length(tokens)
0055         model = model.(tokens{j});
0056     end
0057    
0058     y{i} = model;
0059 end
0060 
0061 %Concationate data by the first singleton dimension
0062 ysize = size(y{1});
0063 
0064 inds = find(ysize ==1);
0065 
0066 if isempty(inds)
0067     inds = length(ysize) +1;
0068 end
0069 
0070 y = cat(inds(1), y{:});
0071         
0072 if exist('plotfunc', 'var') & ~isempty(plotfunc)
0073     h = plotfunc(x, y);
0074 else
0075     h = scatter(x,y);
0076 end
0077 
0078 end

Generated on Sun 29-Sep-2013 18:44:06 by m2html © 2005