Hello,
I have searched online and failed to find an answer and wanted to use some more avenues of support (on top of community support). I have 4 sets of data, each have different amounts of rows/cols, that need to be combined such that I can return a value for any given x and y (within the min/max values of my data). If I have cells that have a common x and y, I wish to average them and add them to a new table. If there are any unique combinations of x and y, I wish to add them as entries. Let me know what are some available methods to do this.
Example output would be
WRT 100 70 50 40 10 5 (example)
60 avg ... ... ...
70 ...
80
90
...

3 件のコメント

Matt J
Matt J 2023 年 5 月 1 日
We need to see an example data set (preferably small), and the desired output for that example.
ALis
ALis 2023 年 5 月 1 日
Edited, let me know if it's clearer.
dpb
dpb 2023 年 5 月 1 日
Not a bit, no...

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

 採用された回答

Joe Vinciguerra
Joe Vinciguerra 2023 年 5 月 2 日

0 投票

Use stack() to restructure your tables, and combine them into a single stacked table like this:
load("Workspace.mat")
combined = table();
for i = 1:length(BoilerArray)
vars = BoilerArray(i).data.Properties.VariableNames;
temp = stack(BoilerArray(i).data, vars(2:end), "NewDataVariableName", "data", "IndexVariableName", "ind");
combined = [combined; temp];
end
From there you can use accumarray() to average any duplicate entries.
Then use unstack() if you wish to return to the original table format.

その他の回答 (0 件)

カテゴリ

製品

リリース

R2023a

質問済み:

2023 年 5 月 1 日

回答済み:

2023 年 5 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by