0001 function dsPlot2D(data,varargin)
0002
0003
0004
0005
0006
0007
0008
0009 options=dsCheckOptions(varargin,{...
0010 'input',[],[],...
0011 },false);
0012
0013 s=data(1).model.specification;
0014
0015 i=1;
0016 popsize=s.populations(i).size;
0017 if isempty(options.input)
0018 input=[];
0019 else
0020 if isfield(data,options.input)
0021 input=data(1).(options.input);
0022 elseif isfield(data(1).model.parameters,options.input)
0023 input=data(1).model.parameters.(options.input);
0024 elseif isfield(data(1).model.fixed_variables,options.input)
0025 input=data(1).model.fixed_variables.(options.input);
0026 else
0027 warning('failed to find input %s',options.input);
0028 input=[];
0029 end
0030 end
0031
0032 ntime=length(data(1).time);
0033 if numel(popsize)==1
0034
0035 width=sqrt(popsize);
0036 X=reshape(data(1).(data(1).labels{1}),[ntime,width,width]);
0037 if ~isempty(input)
0038 input=reshape(input,[ntime,width,width]);
0039 end
0040
0041 elseif numel(popsize)==2
0042
0043 X=data(1).(data(1).labels{1});
0044 width=size(X,2);
0045 end
0046
0047
0048
0049
0050
0051 scrsz = get(0,'ScreenSize');
0052 if ~isempty(input)
0053 Imax = max(input(:));
0054 else
0055 Imax=0;
0056 end
0057 if ~isempty(X)
0058 xmax = max(X(:));
0059 else
0060 xmax=0;
0061 end
0062
0063 fh = figure('Position',[10 scrsz(4)/2-500 0.5.*scrsz(3) 0.75.*scrsz(4)]);
0064
0065 S.sl1 = uicontrol('style','slide',...
0066 'String','time',...
0067 'unit','pix',...
0068 'position',[20 5 150 25],...
0069 'min',1,'max',ntime,'val',1,...
0070 'Callback',@button2_plot);
0071
0072 function button2_plot(hObject,eventdata)
0073 value = get(S.sl1, 'val');
0074
0075 if isempty(input)
0076 nr=2; nc=1; xinds=[1 2];
0077 else
0078 nr=2; nc=2; xinds=[2 4];
0079 end
0080
0081 if ~isempty(input)
0082 subplot(nr,nc,xinds(1)-1)
0083 if ~isempty(input)
0084 surf(squeeze(input(round(value),:,:)));
0085 axis([1 width 1 width 0 Imax 0 1])
0086
0087 axis off
0088 end
0089 subplot(nr,nc,xinds(2)-1)
0090 if ~isempty(input)
0091 imagesc(squeeze(input(round(value),:,:)),[0 Imax]);
0092 title('Input')
0093
0094 axis equal
0095 axis off
0096 end
0097 end
0098
0099 subplot(nr,nc,xinds(1))
0100 if ~isempty(X)
0101 surf(squeeze(X(round(value),:,:)));
0102 axis off
0103 axis([1 width 1 width 0 xmax 0 1])
0104 end
0105
0106 sh=subplot(nr,nc,xinds(2));
0107 if ~isempty(X)
0108 imagesc(squeeze(X(round(value),:,:)),[0 xmax]);
0109
0110 axis equal
0111 title('Activity')
0112
0113 axis off
0114 end
0115
0116 end
0117
0118 end