MATLAB:for循环中绘图的选定标题、xlabel和ylabel

MATLAB:for循环中绘图的选定标题、xlabel和ylabel,matlab,for-loop,plot,Matlab,For Loop,Plot,在Matlab中,我通过一个for循环输出一系列图。在要绘制的for循环中迭代的数据构造在多维矩阵中。但是,我需要for循环中的标题、xlabel和ylabel来更改for循环中每次迭代所选的字符串 代码如下: lat = [40 42 43 45 56]' lon = [120 125 130 120 126]' alt = [50 55 60 65 70]' time = [1 2 3 4 5]' position = cat(3, lat, lon, alt); for k = 1:3

在Matlab中,我通过一个
for循环
输出一系列图。在要绘制的for循环中迭代的数据构造在多维矩阵中。但是,我需要for循环中的
标题
xlabel
ylabel
来更改for循环中每次迭代所选的字符串

代码如下:

lat = [40 42 43 45 56]'
lon = [120 125 130 120 126]'
alt = [50 55 60 65 70]'
time = [1 2 3 4 5]'
position = cat(3, lat, lon, alt);

for k = 1:3
figure
plot(time, position(:,k),'LineWidth', 2, 'Color', 'b')
xlabel('Latitude Time');
ylabel('Latitude Mag');
title('Time v. Latitude');
end 
如何获取打印以输出for循环中的标签,如下所示:

第一次迭代:

xlabel
=纬度时间
ylabel
=纬度磁位
标题
=时间v。纬度

第二次迭代:

xlabel
=经度时间
ylabel
=经度磁标
标题
=时间v。经度

第三次迭代:

xlabel
=高度时间
ylabel
=高度磁标
标题
=时间v。海拔高度

按照注释中的建议,使用单元格数组作为标签并索引到其中:

my_xlabels = {'Latitude Time';'Longitude Time';'Altitude Time'};
my_ylabels = {'Latitude Mag';'Longitude Mag';'Altitude Mag'};
my_titles = {'Time v. Latitude';'Time v. Longitude';'Time v. Altitude'};

for k = 1:3
   figure
   plot(time, position(:,k),'LineWidth', 2, 'Color', 'b')
   xlabel(my_xlabels{k});
   ylabel(my_ylabels{k});
   title(my_titles{k});
end 

制作一个带有标签的单元格数组,然后对其进行索引?