Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
Chiara Scarpellini
Chiara Scarpellini el 12 de Ag. de 2021
Editada: per isakson el 15 de Ag. de 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 comentario
Yazan
Yazan el 15 de Ag. de 2021
Upload your data to make it easier for people to understand your problem, hence provide help.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by