코드 :
%// x = linspace(0,2); %// changed that to respect where the markers are on your example figure
x = 0:0.1:2 ;
y1 = sin(2*pi*x);
y2 = exp(-0.5*2*pi*x).*sin(2*pi*x);
figure
h.axtop = subplot(2,1,1) ;
h.plottop = plot(x,y1,'LineStyle','-','Color','r', ...
'Marker','s', ...
'MarkerEdgeColor','k', ...
'MarkerFaceColor','none', ...
'MarkerSize',8) ;
set(gca,'YLim',[-1 2],'YTick',-1:1:2,'XTick',0:.5:2)
h.ylbl(1) = ylabel('\itf(t)') ; %// label is set in "italic" mode with the '\it' tag at the beginning
h.axbot = subplot(2,1,2);
h.plotbot = plot(x,y2,'-ks', ...
'Marker','*', ...
'MarkerEdgeColor','r', ...
'MarkerSize',8) ;
set(gca,'YLim',[-0.2,0.6],'YTick',[-0.2,0,0.2,0.4,0.6],'XTick',0:.5:2)
h.xlbl(1) = xlabel('Time(s)') ;
h.ylbl(2) = ylabel('\itg(t)') ; %// label is set in "italic" mode with the '\it' tag at the beginning
%// create the "text" annotations
h.txttop = text(0.5,1.5, 'Harmonic force \itf(t)=sin(\omegat)' , 'Parent',h.axtop) ; %// note the 'parent' property set to the TOP axes
h.txtbot = text(0.5,0.3, 'Forced response \itg(t)=e^{\zeta\omegat} sin(\omegat)' , 'Parent',h.axbot) ; %// note the 'parent' property set to the BOTTOM axes
%// set the common properties for all text objects in one go
set([h.xlbl h.ylbl h.txttop h.txtbot] , 'FontName','Times New Roman' , 'FontSize',18)
다음 그림을 생성합니다 : 그래픽 객체의 핸들이 저장된 이후에 속성을 설정하는-재사용 방법
참고. 여러 그래픽 오브젝트 (다른 경우에도)가 동일한 특성을 갖는 경우,이 특성을 모든 그래픽 오브젝트에 한 번에 지정할 수 있습니다.
그림에 주석을 추가하는 방법에 대한 자세한 내용은 Matlab text
함수 설명서를 참조하십시오.
안녕하세요. 감사합니다. 그래프와 모든 것이 맞지만 어떤 이유로 텍스트가 MATLAB R2014a에 표시되지 않지만 Linux 및 matlab 2013이 실행되는 랩 컴퓨터를 사용할 때 나타나지 않습니다. Ps Windows 8을 실행 중이고 명령에서 "unable 라텍스 해석 " –
해석자를 'latex'로 지정해야 할 것입니다 : text (0.5,1.5, '고조파 힘 f (t) = sin (\ omega t)', 'interpreter', 'latex') ' – am304