How to add a column of cell arrays o a table according to data

1 次查看(过去 30 天)
I need to report in the column Var4 of the table SimultedPoints the values of column Discharge of table Name_Code. All of the values of the table Name_Code are present in the table SimulatedPoints. I need to fill the cell arrays of Var4 with the Discahrge values if the Names and Codes matches in the two tables and with zeros if they don't.
E.g
in Var4{idxPoint=1} I should obtain a vector of length 148x1 filled with zeros but a discharge data in correspondence of the position of 7.8675e+04 in the cellarray SimulatedPoints.Codes{idxPoint}
for i=length(Name_Code)
idxPoint=find(Name_Code.Name(i)==SimulatedPoints.Name(:))
length_vector=SimulatedPoints.Codes{idxPoint,:};
n=length(SimulatedPoints.Discharge{idxPoint});
for j=1:length(length_vector)
if length_vector(j)==Name_Code.Codes{i,:}
k(j)=Name_Code.Discharge{i}(j,1);
SimulatedPoints.Var4{idxPoint}=k(j);
else
SimulatedPoints.Var4{idxPoint}k(j);
k(j)=0;
end
end
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by