Meging two tables with different numbers of Rows
조회 수: 16 (최근 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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1212418/image.png)
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 :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1212423/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1212428/image.png)
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!