的兩行我有從EPA的數據集,我已凝結成六列Matlab的:編碼循環語句以減去數據
第一列表示不同public water suppliers
(PWS)。第二個是sampleid number
。第三個是associated sample id number
。標籤開頭處帶有MR的樣品指示出口點。所有其他sample IDs
是具有相關MR的入口點。第四列是sample date
。第五個是個人reference number
。第六欄是sample concentration
。
本質上講我要完成匹配相同PWS
,同樣date
,同樣sample ID
和associate sample id
最後兩者相減sample concentrations
與行相關聯的區別。
我的數據集是6列乘39000行。
這是我曾嘗試代碼:
filename = fopen('Datamine2.csv');
SampleList = textscan(filename,'%s %s %s %s %s %s','Delimiter',',','EmptyValue',0);
fclose(filename);
results = [];
for i = 1:5
if SampleList{3}{i} ~= 0
SampleID1 = SampleList{5}{i};
for j = 1:5
if SampleList{2}{j} == SampleList{3}{i} && SampleList{1}{j} == SampleList{1}{i} && SampleList{4}{j} == SampleList{4}{i}
SampleID2 = SampleList{5}{j};
SampleDiff = str2double(SampleList{6}{i}) - str2double(SampleList{6}{j});
newresults = [SampleList{1}{i} SampleList{4}{i} SampleDiff SampleID1 SampleID2];
results = [results;newresults]
end
end
end
end
但是這是我收到的錯誤:
EDU >>使用==矩陣尺寸必須同意運行epadata錯誤。
錯誤epadata(10號線)
if SampleList{2}{j} == SampleList{3}{i} && SampleList{1}{j} == SampleList{1}{i} && SampleList{4}{j} == SampleList{4}{i}
錯誤運行(64行)
evalin('caller', [script ';']);
誰能提供任何指引到解決這個? 很多很多,謝謝。
使用[MATLAB的調試器](http://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html)來驗證您用於每個比較的所有單元格是相同的大小。 – excaza