www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregmodel/movie.m
function M= movie(m,x,TVar,hAx,AxesPos,xtrans,cmodel) %MOVIE movie of model surface % % M= movie(m,x,TVar,hAx,AxesPos,xtrans,cmodel) % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. hFig= ancestor(hAx,'figure'); set(hFig,'CurrentAxes',hAx); % Area for Movie GetFrame if nargin<5 oldu= get(hAx,'Units'); set(hAx,'Units','pixels'); AxesPos= get(hAx,'Position'); set(hAx,'Units',oldu); end if nargin<6 xtrans=1; end if nargin<7 cmodel=[]; end Tvalues= x{TVar}; s= get(m,'symbol'); [Y2,X]= GenTable(m,x); tf=figure('Visible','off'); ah= axes('Parent',tf); plot(Y2(:),'Parent',ah); % Range for whole plot ZRange= get(ah,'YLim'); % Try to find some suitable levels for the contour plot V= get(ah,'YTick'); % delete Temp Figure % need to use a subsref call to index time as we don't % know which dimension it is. The following two lines % build the necessary structure. S= struct('subs',':','type','()'); S.subs= repmat({':'},length(x),1); ratio = 1; % Try 1st, middle, last plots for i=[1 max(1,fix(length(Tvalues)/2)) length(Tvalues)] S.subs{TVar} = i; Y= subsref(Y2,S); plot(Y(:)) V1= get(ah,'YTick'); ratio= max(ratio,diff(V(1:2))/diff(V1(1:2))); end delete(tf) x{TVar}=1; if istransient(m) error(message('mbc:xregmodel:InvalidModel')) else [X{:}]=ndgrid(x{:}); end % Loop through all Time values for i=1:length(Tvalues) % Grab Table for CurrentTime x{TVar}= Tvalues(i); S.subs{TVar}= i; Y= subsref(Y2,S); delete(get(hAx,'Children')); surface(m,x,hAx,[0,xtrans],cmodel,X,Y,Y); Tname= sprintf('%s (%s=%5g)',m.Output.Name,s{TVar},Tvalues(i)); set(hAx,'ZLim',ZRange) set(get(hAx,'Title'),... 'String',Tname,... 'Interpreter','none'); drawnow % Grab frame for movie M(i)= getframe(hFig,AxesPos); end set(hAx,'UserData',Y2);