我正在尝试将文本文件中的数字列保存在单独的数组中,以便可以绘制它们。我的代码对于第一列工作正常,但是我似乎无法保存后面的数组。如果放置Y(j)
,则数组将扩展为38列。我也尝试使用Y(1:19)
,但这仅保存了最后一个值。
m = dlmread("result.txt");
X = zeros (1,19);
for i = 1:19
x = m(i);
X (i) = x;
end
Y = zeros (1,19);
for j = 20:38
y = m(j);
Y (j) = y;
end
plot (X,Y,'*')
这是我的文本文件中的数据:
-117.482071 , 38.587502 , 1889.332764
-127.234932 , -134.117035 , 1862.899170
-295.751495 , -137.280533 , 1870.713989
-396.392212 , -342.627838 , 1797.450195
-364.200378 , -82.991661 , 1732.802490
30.170357 , -149.174057 , 1912.513794
137.002335 , -363.414001 , 1893.756470
132.693115 , -124.178337 , 1769.763306
-129.690857 , -365.272583 , 1854.689697
-132.590271 , -530.044312 , 1816.501099
-230.024750 , -573.607178 , 1800.884766
-192.102402 , -904.118896 , 1666.393433
-192.102402 , -1241.659302 , 1666.393433
-37.203903 , -579.247864 , 1821.582275
-37.203903 , -938.084900 , 1821.582275
-37.203903 , -1275.625244 , 1821.582275
-369.565674 , -126.264359 , 1743.577148
133.411316 , -164.050949 , 1790.428833
-126.466972 , -61.835381 , 1865.466309