How to concatenate 4 columns in one table into one coulomb
3 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Khushboo
on 31 Oct 2022
Edited: Khushboo
on 31 Oct 2022
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 Comments
Lei Hou
on 18 Nov 2022
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 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!