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

4 ビュー (過去 30 日間)
Chiara Scarpellini
Chiara Scarpellini 2021 年 8 月 12 日
編集済み: per isakson 2021 年 8 月 15 日
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 件のコメント
Yazan
Yazan 2021 年 8 月 15 日
Upload your data to make it easier for people to understand your problem, hence provide help.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by