⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dfield7.m

📁 matlab of linear system
💻 M
📖 第 1 页 / 共 5 页
字号:
	  nstr(1:4) = nstr(2:5);	  nstr{5} = ['The forward orbit from',ptstr];	  set(notice,'string',nstr);	end	drawnow						[tp,xp] = feval(solvhandle,dfcn,intplus,initpt(2),disph);	aud = get(dfdispa,'user');	hnew1 = aud.line;	set(aud.pline,'erase','normal','color', pcol);  	dud.plhand=[dud.plhand;aud.pline];         end		            if intminus(2) < intminus(1)	cflag = cflag + 2;	if notice		  nstr = get(notice,'string');	  nstr(1:4) = nstr(2:5);	  nstr{5} = ['The backward orbit from',ptstr];	  set(notice,'string',nstr);	end	drawnow		[tm,xm] = feval(solvhandle,dfcn,intminus,initpt(2),disph);	aud = get(dfdispa,'user');	hnew2 = aud.line;	set(aud.pline,'erase','normal','color', pcol);     	dud.plhand=[dud.plhand;aud.pline];   	set(stopbutt,'vis','off');      end	  % if intminus(2) < intminus(1)	            % Store the trajectory.            switch cflag       case 1 % positive only	set(hnew1,'xdata',tp(:),'ydata',xp(:),'color',pcol);	set(hnew1,'erase','normal');	dud.solhand = [dud.solhand;hnew1];	       case 2 % negative only	x = flipud(xm);	t = flipud(tm);	set(hnew2,'xdata',t(:),'ydata',x(:),'color',pcol);	set(hnew2,'erase','normal');	dud.solhand = [dud.solhand;hnew2];	       case 3 % both directions	x = flipud(xm);	t = flipud(tm);	x=[x;xp];	t=[t;tp];	delete(hnew1);	set(hnew2,'xdata',t(:),'ydata',x(:),'color',pcol);	set(hnew2,'erase','normal');	dud.solhand = [dud.solhand;hnew2];      end	 % switch cflag      set(disph,'user',dud);        elseif strcmp(action,'kcompute')      % 'kcompute' is the call back for the Compute     % button on the dfield7 Keyboard figure.        compute = 1;    kh = get(gcf,'user');    dfdisp = findobj('name','dfield7 Display');    if (isempty(dfdisp))      dfield7('confused');    end    dud = get(dfdisp,'user');    dfdispa = dud.axes;    aud = get(dfdispa,'user');    dfset = findobj('name','dfield7 Setup');    sud = get(dfset,'user');    ch = findobj('type','uicontrol','enable','on');    set(ch,'enable','inactive');    set(dfdisp,'WindowbuttonDownFcn','');    xstr = get(kh.xval,'string');    tstr = get(kh.tval,'string');    pnameh = sud.h.pname;    pvalh = sud.h.pval;    pflag = zeros(1,4);    perr = [];    for kk = 1:4;      pn = char(get(pnameh(kk),'string'));      pv = char(get(pvalh(kk),'string'));      if ~isempty(pn)	if isempty(pv) 	  perr = pvalh(kk);	else 	  xstr = dfield7('paraeval',pn,pv,xstr);	  tstr = dfield7('paraeval',pn,pv,tstr);	end      end    end    xvalue = str2num(xstr);    tvalue = str2num(tstr);            if get(kh.spec,'value')      t0 = str2num(get(kh.t0,'string'));      tf = str2num(get(kh.tf,'string'));      initpt = [tvalue,xvalue,t0,tf];      if (length(initpt) ~= 4)	warndlg({'Values must be entered for all of the entries.'},...		'Illegal input');	compute = 0;      elseif tf <= t0	warndlg({'The final time of the computation interval';...		 'must be smaller than the initial time.'},'Illegal input');	compute = 0;      elseif (tvalue < t0) | (tvalue > tf)	warndlg('The initial time must be in the computation interval.',...		'Illegal input');	compute = 0;      end      aud.gstop = 0;      set(dfdispa,'user',aud);    else      initpt = [tvalue,xvalue];      if (length(initpt) ~= 2)	warndlg({'Values must be entered for all of the entries.'},...		'Illegal input');	compute = 0;      end    end	% if get(kh.spec,'value')        if compute      dfield7('solution',initpt,dfdisp);    end    nstr = get(dud.notice,'string');    nstr(1:4) = nstr(2:5);    nstr{5} = 'Ready.';    set(dud.notice,'string',nstr)    %  set([ch;mh],'enable','on');    set(ch,'enable','on');    set(dfdisp,'WindowbuttonDownFcn','dfield7(''down'')');    aud.gstop = 1;    set(dfdispa,'user',aud);          elseif strcmp(action,'kbd')        % 'kbd' is the callback for the Keyboard Input menu selection.  It     % sets up the dfield7 Keyboard figure which allows accurate input of     % initial values using the keyboard.        ppkbd = findobj('name','dfield7 Keyboard input');    if ~isempty(ppkbd)      delete(ppkbd);    end        dfdisp = gcf;    dud = get(dfdisp,'user');    Xname = dud.syst.xname;    Tname = dud.syst.tname;    xnstr = ['The initial value of ',Xname,' = '];    tnstr = ['The initial value of ',Tname,' = '];        ppkbd = figure('name','dfield7 Keyboard input',...		   'vis','off',...		   'numb','off','tag','dfield7');        dfield7('figdefault',ppkbd);    set(ppkbd,'menubar','none');        kbd.fr1 = uicontrol('style','frame');        kbd.fr2 = uicontrol('style','frame');        kbd.inst = uicontrol('style','text','horiz','center',...			 'string','Enter the initial conditions:');        kbd.xname = uicontrol('style','text',...			  'horiz','right','string',xnstr);        kbd.tname = uicontrol('style','text',...			  'horiz','right',...			  'string',tnstr);        kbd.tval = uicontrol('style','edit','background','w');        kbd.xval = uicontrol('style','edit',...			 'string','','call','','background','w');        kbd.t0 = uicontrol('style','edit','background','w');        kbd.tf = uicontrol('style','edit','background','w');        tstring = ['<= ',Tname,' <='];    kbd.t = uicontrol('style','text','string',tstring);        kbd.spec = uicontrol('style','check','horiz','center',...			 'string','Specify a computation interval.');      kbd.comp = uicontrol('style','push',...					 'string','Compute','call','dfield7(''kcompute'')');        kbd.close = uicontrol('style','push',...			  'string','Close','call','close');        nudge = 3;     left = 3; varl = 80; buttw = 60;    xex = get(kbd.xname,'extent');    ht = xex(4)+nudge;    yex = get(kbd.tname,'extent');    nwdth = max(xex(3),yex(3)) + nudge;    varl = varl*ht/19;    fr1bot = left + ht;    fr1ht = 3*nudge + 2*ht;    fr2bot = fr1bot + fr1ht;    frw = 2*nudge + nwdth + varl;    intb = fr1bot + nudge;    specb = intb + ht + nudge;    intext = get(kbd.t,'extent');    tw = intext(3);    newwidth = tw + 2*varl +2*nudge;    frw = max(frw,newwidth);    margin = (frw -tw - 2*varl)/2;    t0l = left+margin;    tl = t0l + varl;    tfl = tl + tw;    xnb = fr2bot + nudge;    tnb = xnb + ht;    nl = left+nudge;    xnwind = [nl,xnb-.15*ht,nwdth,ht];    tnwind = [nl,tnb-.15*ht,nwdth,ht];    vl = nl + nwdth;    xvwind = [vl,xnb,varl,ht];    tvwind = [vl,tnb,varl,ht];    instb = tnb + ht + nudge;    instw = nwdth + varl;    instwind = [nl,instb,instw,ht];    fr2ht = 3*nudge + 3*ht;    % frw = 2*nudge + nwdth + varl;    fr2wind = [left,fr2bot,frw,fr2ht];    fr1wind = [left,fr1bot,frw,fr1ht];    specw = frw - 2*nudge;    specwind = [nl,specb,specw,ht];    t0wind = [t0l,intb,varl,ht];    twind = [tl,intb-.15*ht,tw,ht];    tfwind = [tfl,intb,varl,ht];    figw = 2*left + frw;    fight = 3*left + ht + fr1ht + fr2ht;    figwind = [30,300,figw,fight];    buttw = frw/2;    sep = (figw - 2*buttw)/3;    closel = left;    compl = closel+buttw;    clwind = [closel,left,buttw,ht];    compwind = [compl,left,buttw,ht];    set(ppkbd,'pos',figwind);    set(kbd.fr1,'pos',fr1wind);    set(kbd.fr2,'pos',fr2wind);    set(kbd.inst,'pos',instwind);    set(kbd.xname,'pos',xnwind);    set(kbd.tname,'pos',tnwind);    set(kbd.xval,'pos',xvwind);    set(kbd.tval,'pos',tvwind);    set(kbd.comp,'pos',compwind);    set(kbd.close,'pos',clwind);    set(kbd.tname,'pos',tnwind);    set(kbd.tval,'pos',tvwind);    set(kbd.spec,'pos',specwind);    set(kbd.t0,'pos',t0wind);    set(kbd.t,'pos',twind);    set(kbd.tf,'pos',tfwind);    speccall = [	'ud = get(gcf,''user'');',...	'if get(gcbo,''value''),',...	'  set([ud.t0,ud.t,ud.tf],''enable'',''on'');',...	'  set([ud.t0,ud.tf],''background'',[1 1 1]);',...	'else,',...	'  set([ud.t0,ud.t,ud.tf],''enable'',''off'');',...	'  set([ud.t0,ud.tf],''background'',[0.83 0.82 0.78]);',...	'end'];        set(kbd.spec,'call',speccall);    set(ppkbd,'resize','on');    set(findobj(ppkbd,'type','uicontrol'),'units','normal');        set(kbd.spec,'value',0);    set(ppkbd,'user',kbd,'vis','on');    set([kbd.t0,kbd.tf],'enable','off',...		      'background',[0.83 0.82 0.78]);    set(kbd.t,'enable','off');    set(findobj(ppkbd,'type','uicontrol'),'units','normal');    figure(ppkbd)      elseif strcmp(action,'zoomin')      % 'zoomin' is the callback for the Zoomin menu item.  It allows the    % user to pick a new display rectangle.        set(gcf,'WindowButtonDownFcn','dfield7(''zoom'')',...	    'WindowButtonUpFcn','1;','inter','on');    set(gca,'inter','on');    dud = get(gcf,'user');    nstr = get(dud.notice,'string');    nstr(1:4) = nstr(2:5);    nstr{5} = ['Pick a new display rectangle by clicking and ',...	       'dragging the mouse, or by clicking on a point.'];    set(dud.notice,'string',nstr);      elseif strcmp(action,'zoom')        disph = gcf;    dud = get(disph,'user');    axh = dud.axes;    aud = get(axh,'user');    DY = aud.DY;    w = dud.syst.wind;    q1 = get(disph,'currentpoint');    p1 = get(axh,'currentpoint');    p1 = p1(1,1:2);    rbbox([q1 0 0],q1);    p2 = get(axh,'currentpoint');    p2 = p2(1,1:2);    if all(abs(p1'-p2')>0.01*DY)      a = [p1;p2];      a = [min(a);max(a)];      DY = (a(2,:) - a(1,:))';      else      DY = DY/4;      a(1) = max(w(1),p1(1)-DY(1));      a(2) = min(w(2),p1(1)+DY(1));      a(3) = max(w(3),p1(2)-DY(2));      a(4) = min(w(4),p1(2)+DY(2));      DY(1) = a(2) - a(1);      DY(2) = a(4) - a(3);    end        WINvect = a(:)';    dud.syst.wind = WINvect;    aud.DY = DY;    dwind = [WINvect(1); WINvect(3); -WINvect(2); -WINvect(4)];    aud.cwind = WINvect(:) - ...	dud.settings.magn*[DY(1);-DY(1);DY(2);-DY(2)];    set(axh,'user',aud);	    set(disph,'user',dud);    set(disph,'WindowButtonDownFcn','dfield7(''down'')',...	      'WindowButtonUpFcn','');    dfield7('dirfield',disph);    dfset = findobj('name','dfield7 Setup');    if isempty(dfset)      dfield7('confused');    else      sud = get(dfset,'user');      sud.c.wind = WINvect;      sud.o.wind = WINvect;      set(sud.h.wind(1),'string',num2str(WINvect(1)));      set(sud.h.wind(2),'string',num2str(WINvect(2)));      set(sud.h.wind(3),'string',num2str(WINvect(3)));      set(sud.h.wind(4),'string',num2str(WINvect(4)));      set(dfset,'user',sud);    end      elseif strcmp(action,'dall')      % 'dall' is the callback for the Erase all graphics objects.          disph = gcf;    dud = get(disph,'user');    notice = dud.notice;    kk = find(ishandle(dud.solhand));        delete(dud.solhand(kk));    dud.solhand = [];    kk = find(ishandle(dud.plhand));        delete(dud.plhand(kk));    dud.plhand = [];    kk = find(ishandle(dud.contours));        delete(dud.contours(kk));    dud.contours = [];    if notice      set(dud.butt(1),'enable','off');    end    set(disph,'user',dud);      elseif strcmp(action,'dallsol')        % 'dallsol' is the callback for the Erase all solutions option.          disph = gcf;    dud = get(disph,'user');    notice = dud.notice;    kk = find(ishandle(dud.solhand));          delete(dud.solhand(kk));    dud.solhand = [];    kk = find(ishandle(dud.plhand));        delete(dud.plhand(kk));    dud.plhand = [];    if notice      set(dud.butt(1),'enable','off');    end    set(disph,'user',dud);      elseif strcmp(action,'dalllev')        % 'dalllev' is the callback for the Erase all level curves option.          disph = gcf;    dud = get(disph,'user');    notice = dud.notice;    kk = find(ishandle(dud.contours));           delete(dud.contours(kk));    dud.contours = [];    if notice      set(dud.butt(1),'enable','off');    end    set(disph,'user',dud);      elseif strcmp(action,'solvset')        dud = get(gcf,'user');    name = dud.settings.solver;        setfig = findobj('name','dfield7 Solver settings');    if ~isempty(setfig)      data = get(setfig,'user');      if strcmp(data.settings.solver,name)	figure(setfig);	return      else	close(setfig);      end    end    data.settings = dud.settings;        nstepcall =['data = get(gcf,''user'');',...		'ss = max(round(str2num(get(data.d1,''string''))),1);',...		'data.settings.refine = ss;',...		'set(data.d1,''string'',num2str(ss));',...		'set(data.chb,''enable'',''on''),',...		'set(gcf,''user'',data);'];        ssizecall = ['data = get(gcf,''user'');',...		 'data.settings.stepsize = str2num(get(data.d1,''string''));',...		 'set(data.d1,''string'',num2str(data.settings.stepsize));',...		 'set(data.chb,''enable'',''on''),',...		 'set(gcf,''user'',data);'];        chcall = ['data = get(gcf,''user'');',...	      'dfdisp = findobj(''name'',''dfield7 Display'');',...	      'dud = get(dfdisp,''user'');',...	      'dud.settings = data.settings;',...	      'set(dfdisp,''user'',dud);',...	      'dfset = findobj(''name'',''dfield7 Setup'');',...	      'ud = get(dfset,''user'');',...	      'ud.settings = data.settings;',...	      'set(dfset,''user'',ud);',...	      'set(data.chb,''enable'',''off'');'];     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -