How to concatenate 4 columns in one table into one coulomb
조회 수: 3 (최근 30일)
이전 댓글 표시
Table 1
imageFilename xmin ymin xmax ymax
________________________________________________________ ____ ____ ____ ____
Japan_001164_jpg.rf.c02ee7802c701e228f23a4033eb236c2.jpg 384 383 415 406
*** Table 2 (result) ***
imageFilename Damage
_______________________________________________________________________________________________ _________________
{'C:\Users\msi-pc\Desktop\Training\New folder (2)\train\Japan_000001_jpg.rf.7b3ecaac169c998a18815a31934dbbea.jpg'} {[384 383 415 406]}
댓글 수: 0
답변 (2개)
Khushboo
2022년 10월 31일
편집: Khushboo
2022년 10월 31일
Hello,
You can concatenate different columns in a table using MATLAB's strcat function as follows:
% Input table
imageFilename = {'Japan_001164_jpg.rf.c02ee7802c701e228f23a4033eb236c2.jpg'};
xmin = {384};
ymin = {313};
xmax = {415};
ymax = {406};
t1 = table(imageFilename, xmin, ymin, xmax, ymax);
% Create table with concatenated columns
concatenatedCols = strcat(t1.xmin, t1.ymin, t1.xmax, t1.ymax);
t2 = table(imageFilename, concatenatedCols);
Hope this answers your question!
댓글 수: 0
Lei Hou
2022년 11월 18일
Hi,
You can you mergevars to merge table variables.
>> t = table("Japan_001164_jpg.rf.c02ee7802c701e228f23a4033eb236c2.jpg",384,383,415,406,'VariableNames',["imageFileName" "xmin" "ymin" "xmax" "ymax"])
t =
1×5 table
imageFileName xmin ymin xmax ymax
__________________________________________________________ ____ ____ ____ ____
"Japan_001164_jpg.rf.c02ee7802c701e228f23a4033eb236c2.jpg" 384 383 415 406
>> mergevars(t,["xmin" "ymin" "xmax" "ymax"])
ans =
1×2 table
imageFileName Var2
__________________________________________________________ ________________________
"Japan_001164_jpg.rf.c02ee7802c701e228f23a4033eb236c2.jpg" 384 383 415 406
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!