所以我有这个大文本文件,我必须从它的三个列中提取一些信息。所以我想这样做的方法是在第一个数量大于零时保存索引,使用该索引开始搜索第二列以查看其值何时变为常量,保存该索引并存储该值直到它保持不变在矩阵中。对于那些少数索引,我还需要从另一列中提取值并保存它们。
到目前为止,这是我对代码所拥有的内容:
%Open a file
filename = uigetfile(['*.dat'], 'Select file');
data = importdata(filename);
%Selecting Mach Number from the data
Mach_Number = data(:,4);
RPM = data(:,19);
Torque = data(:,20);
index1 = 0;
index2 = 0;
%Selecting a portion of Mach Number that corresponds to constant RPM
for i = 2:size(RPM,1)
if (RPM>0)
index1 = i;
for j = index1:size(Mach_Number,1)
if (-0.00001<Mach_Number<0.00001)
index2 = j;
end
end
end
end
newMach = Mach_Number(index2)
newRPM = RPM(index1)