t = linspace(0,10,50); plot(t,sin(t)) h = get(gca,'children'); set(h,'Marker','o') set(get(gca,'children'),'Marker','o') >> get(gca,'xlim') ans = 0 10 >> get(gca,'ylim') ans = -1 1 >> get(gca,'xtick') ans = 0 2 4 6 8 10 >> get(gca,'linewidth') ans = 0.5 >> get(gca) >> get(h) h = plot(t,sin(t)); set(h,'Marker','o') axes('Position',[.1 .5 .8 .08],'TickDir','out',... 'YDir','reverse','xax','top') >> set(gca,'XAxisLocation') function oops(N) % OOPS Delete the last object plotted on the axes. % Repeating "oops" erases farther back in time. % OOPS does not work for title and labels; to % erase these, use "title('')" or "xlabel('')" if nargin = = 0 N = 1; end h = get(gca,'children'); delete(h(1:N)); clf plt(x,f(x)) hold on plt(x,f(x/2)) oops x = -1:.01:1; f = inline('x.^2'); clf plt(x,f(x),x,sqrt(f(x))) xt = [-.5 -.5]; yt = [f(-.5) sqrt(f(-.5))]; text(xt,yt,{' |x|' ' x^2'}) oops(2) text(xt,yt,{' x^2' ' |x|'}) figure get(gcf,'position') ans = 291 445 560 420 >> get(gcf,'units') ans = pixels >> set(gcf,'units') [ inches | centimeters | normalized | points | pixels ] >> set(gcf,'units','norm') >> get(gcf,'units') ans = normalized >> get(gcf,'position') ans = 0.2517 0.4933 0.4861 0.4667 set(gcf,'pos',[0 0 .5 .5]) figure('units','norm','pos',[.5 0 .5 .5]) gcf: get(0,'CurrentFigure') gca: get(gcf,'CurrentAxes') gco: get(gcf,'CurrentObject') ===================================================================== h = uicontrol; >> get(h,'style') ans = pushbutton >> set(h,'style') [ {pushbutton} | togglebutton | radiobutton | checkbox | edit | text | slider | frame | listbox | popupmenu ] uicontrol('String','Do plot','CallBack','plot(humps)') uicontrol('Callback','ezplot(''sin(x)'')', ... 'Position',[508 351 51 26],'String','Sine'); uicontrol('Callback','ezplot(''cos(x)'')', ... 'Position',[508 322 51 26],'String','Cos'); uicontrol('Callback','ezplot(''tan(x)'')', ... 'Position',[508 293 51 26],'String','Tan'); function trigplt(action) if nargin = = 0 % Create the GUI: uicontrol('Callback','trigplt Sine',... 'Position',[508 351 51 26],'String','Sine'); uicontrol('Callback','trigplt Cosine',... 'Position',[508 322 51 26],'String','Cos'); uicontrol('Callback','trigplt Tangent',... 'Position',[508 293 51 26],'String','Tan'); else % Perform the action: x = linspace(0,2*pi); switch(action) case 'Sine' y = sin(x); titstr = 'y = sin(x)'; case 'Cosine' y = cos(x); titstr = 'y = cos(x)'; case 'Tangent' y = tan(x); titstr = 'y = tan(x)'; end plot(x,y) end h = uicontrol('style','edit','String','Hello'); set(h,'string','Bye') >> get(h,'string') ans = qwe >> x = get(h,'string') x= 10.3 >> x+1 ans = 50 49 47 52 >> str2num(x) + 1 ans = 11.3000 uicontrol('Pos',[110 280 60 19],'Style','text','String','Name:'); uicontrol('Pos',[175 280 246 19],'Style','edit'); uicontrol('Pos',[110 262 60 19],'Style','text',... 'String','Address:'); uicontrol('Pos',[175 262 246 19],'Style','edit'); uicontrol('Pos',[110 243 60 19],'Style','text','String','Sex:'); uicontrol('Pos',[175 243 121 19],'Style','radiobutton',... 'String','Male'); uicontrol('Pos',[301 243 121 19],'Style','radiobutton',... 'String','Female'); uicontrol('Position',[99 231 332 77],'Style','frame'); uicontrol('Position',[110 280 60 19],'Style','text',... 'String','Name:'); uicontrol('Position',[175 280 246 19],'Style','edit'); uicontrol('Position',[110 262 60 19],'Style','text',... 'String','Address:'); uicontrol('Position',[175 262 246 19],'Style','edit'); uicontrol('Position',[110 243 60 19],'Style','text',... 'String','Sex:'); uicontrol('Position',[175 243 121 19],'Style','radiobutton',... 'String','Male'); uicontrol('Position',[301 243 121 19],'Style','radiobutton',... 'String','Female'); h = uicontrol('style','slider'); set(h,'pos',[50 200 450 40]) set(h,'callback','disp(get(h,''value''))') clf hsl = uicontrol('Position',[200 260 200 20], ... 'Style','slider','Value',0.5,... 'CallBack',... 'set(hed,''String'',num2str(get(hsl,''value''),2))'); hed = uicontrol('BackgroundColor',[1 1 1], ... 'Position',[200 240 70 20], ... 'String','0.5','Style','edit',... 'CallBack',... 'set(hsl,''Value'',str2num(get(hed,''String'')))'); set(h,'String',{'Red';'Green';'Blue'}) set(h,'String','Red|Green|Blue') set(h,'String',[1;10;100]) set(h,'String',1:3) set(h,'String',['Red ';'Green';'Blue ']) h = uicontrol('pos',[168 219 89 116], ... 'Style','listbox', ... 'String',{'Red';'Green';'Blue'}); set(h,'string',{'Red';'Green';'Blue';... 'Pale Goldenrod';'Orange';'yellow'}) set(h,'style','popup',... 'pos',[168 219 145 32]) function exradio(action) if nargin = = 0 clf uicontrol('Position',[200 321 90 25], ... 'String','JJJ', ... 'Style','radiobutton',... 'CallBack','exradio(1)') uicontrol('Position',[200 296 90 25], ... 'String','ABC-FM', ... 'Style','radiobutton',... 'CallBack','exradio(1)') uicontrol('Position',[200 271 90 25], ... 'String','SAFM', ... 'Style','radiobutton',... 'CallBack','exradio(1)') uicontrol('Position',[200 246 90 25], ... 'String','5AD', ... 'Style','radiobutton',... 'CallBack','exradio(1)') else h = findobj('style','radiobutton'); ind = find(h~ = gco); set(h(ind),'value',0) end clf set(gcf,'doublebuffer','on') h = plot(0,0,'.'); for i = 1:1000 t = linspace(0,2*pi,i); set(h,'xdata',t,'ydata',sin(370*t)) drawnow end