Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Chiara Scarpellini
Chiara Scarpellini le 12 Août 2021
Modifié(e) : per isakson le 15 Août 2021
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
  1 commentaire
Yazan
Yazan le 15 Août 2021
Upload your data to make it easier for people to understand your problem, hence provide help.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by