Matlab 在一个窗口中用两个图形标记不同的轴

Matlab 在一个窗口中用两个图形标记不同的轴,matlab,plot,matlab-figure,Matlab,Plot,Matlab Figure,我尝试以不同的方式为这些图形标记轴,我尝试仅将一个x轴标记为“时间(s)”,将第一个y轴标记为“f(t)”,将第二个y轴标记为“g(t)”。我的书在实现某种字体和大小的同时,并没有明确说明如何做到这一点,互联网也没有太大帮助。 我知道我必须实现这一点,但我不知道在哪里: % swEPSfigure.m % % Set the default font names and sizes for the eps figures % prepared for Scientific Word % In S

我尝试以不同的方式为这些图形标记轴,我尝试仅将一个x轴标记为“时间(s)”,将第一个y轴标记为“f(t)”,将第二个y轴标记为“g(t)”。我的书在实现某种字体和大小的同时,并没有明确说明如何做到这一点,互联网也没有太大帮助。

我知道我必须实现这一点,但我不知道在哪里:

% swEPSfigure.m
%
% Set the default font names and sizes for the eps figures
% prepared for Scientific Word
% In SW, a 65-50% reduction of the figures is normally done
% Full LaTeX commands can be used in the labels, legends, etc.
%
%
set(0,'DefaultAxesFontName','Times New Roman');
set(0,'DefaultTextFontName','Times New Roman');
set(0,'DefaultAxesFontSize',18);
set(0,'DefaultTextFontSize',18);
set(0,'defaulttextinterpreter','latex'); % Use LaTeX to add Math symbols
disp(' ');
disp(' Changing Default Font to Times New Roman');
disp(' Changing Default Font Size to 18');
disp(' ');
这是我当前的代码:

x = linspace(0,2);
y1 = sin(2*pi*x);
y2 = exp(-0.5*2*pi*x).*sin(2*pi*x);

figure
subplot(2,1,1);
hPlot1 = plot(x,y1,'rs');

set(gca,'YLim',[-1 2],'YTick',-1:1:2,'XTick',0:.5:2)

subplot(2,1,2);
hPlot2 = plot(x,y2,'k*');

set(gca,'YTick',[-0.2,0,0.2,0.4,0.6],'XTick',0:.5:2)

要更改标签,需要获取标签本身的句柄。 固定代码:

x = linspace(0,2);
y1 = sin(2*pi*x);
y2 = exp(-0.5*2*pi*x).*sin(2*pi*x);

figure
subplot(2,1,1);
hPlot1 = plot(x,y1,'rs');

set(gca,'YLim',[-1 2],'YTick',-1:1:2,'XTick',0:.5:2)
set(get(gca,'XLabel'),'String','X axis label 1') %get the handle to XLabel and set its value 
set(get(gca,'YLabel'),'String','Y axis 1') %get the handle to YLabel and set its value 

subplot(2,1,2);
hPlot2 = plot(x,y2,'k*');

set(gca,'YTick',[-0.2,0,0.2,0.4,0.6],'XTick',0:.5:3)
set(get(gca,'XLabel'),'String','X axis label 2') %get the handle to XLabel and set its value 
set(get(gca,'YLabel'),'String','Y axis 2') %get the handle to YLabel and set its value