matlab - 深复制浅复制 Matlab 结构/结构字段
问题描述
嗨,我想在对mySTruct
结构字段进行一些减法后更改结构。mySTruct
如何在不使用(......)解决路径的情况下将我的新结构复制到其中mySTruct.KMZ
我需要将结果复制到mySTruct
(mySTruct.KMZ.Lstgn.Abkm
)深度 3 的单元格中我的代码的重要部分是这个计算
currentFile = mySTruct .(subsref(fieldnames(mySTruct ),substruct('{}',{k})));
for idx = 2 : cellRowSize
display(idx)
resForLstg(idx,1) = table(currentEnergie(idx,2)-currentEnergie(idx-1,2));
%Res for column 2
resForLstg(idx,2) = table(currentEnergie(idx,3)-currentEnergie(idx-1,3));
%Res for column 3
currentFile.Lstg.(subsref(fieldnames(currentFile.Energie),substruct('{}',{i}))) = resForLstg;
问题是这currentFile
是一个新的独立结构,与 Struct 没有任何共同之处mySTruct
。我的代码的最后一行发生了变化mySTruct