为了使这个问题更容易描述,我提供了下面的示例代码,它与我正在使用的实际数据类似:
clear all
AirT = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
SolRad = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
Rain = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
Location = {'England','Wales','Scotland','Ireland'};
points = {'old','old','old','new'};
CorrVariables = {'AirT','SolRad','Rain'};
for i = 1:length(Location);
Data = @(location) struct('Location',location,CorrVariables{1},AirT{i},...
CorrVariables{2},SolRad{i},CorrVariables{3},Rain{i});
D(i) = Data(Location{i});
end
FieldName = {D.Location};
R = corrcoef([D.AirT],'rows','pairwise');
R_Value = [Location(nchoosek(1:size(R,1),2)) num2cell(nonzeros(tril(R,-1)))];
q = points(nchoosek(1:size(R,1),2));
%to calculate the combination of these points we need to convert the
%cell into a matrix.
Re = [R_Value q];在这个例子中,我想在Re的第5列中创建另一个单元格数组,它依赖于列4和列5中的字符串。因此,如果Re中的列4和列5相等,例如'old''old',那么列6应该显示'老'。但是,如果细胞不同,例如'old''new',那么我希望新的单元格数组(即Re中的第6列)陈述'old / new'。
这将如何成为可能?