Meging two tables with different numbers of Rows
17 次查看(过去 30 天)
显示 更早的评论
Hallo,
I have two tables with different rows numbers and the final goal is to export these Data in excel File by using the Function " writetable ".
The first table contains Data of Maxima and Minima (as in the Image down). The second Table contains the increment Values of Maxima and Minima, they are always less Values and less rows than the Max.-Min.
First thing i have transfered the Data to Table as follow :
MaxMin = table(DehnungMax,DehnungMin);
Ink = table(DehnunungMax_inkr,DehnunungMin_inkr);
The Problem by using the function " outer join " asking always for Key variables, but theoretically there is no key.
I am trying even if Possible to put the increment of each Maxima and Minima under them in the same Column but divide the both Values with Header. or Even beside each other okay also. as Follow :
Thank you very much for any Help or Suggestion.
0 个评论
采纳的回答
Vilém Frynta
2022-11-29
编辑:Vilém Frynta
2022-11-29
Try:
% Random data to work with
DMax = [1 2 3 4 5]';
DMin = [0.1 0.2 0.3 0.4 0.5]';
DMaxInk = [11 22 33 44]';
DMinInk = [0.11 0.22 0.33 0.44]';
% Create table and create columns DMax and DMin
T = table;
T.DMax = DMax;
T.DMin = DMin;
If this is just one-time thing and you do not wish to automate this process, you can match the lengths by adding empty values.
% Adding NaN values on the end
DMaxInk(end+1,1) = NaN;
DMinInk(end+1,1) = NaN;
% Create columns for DMaxInk and DMinInk
T.DMaxInk = DMaxInk;
T.DMinInk = DMinInk
% Save the table
writetable(T,"your_table_name.xlsx");
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!