How to concatenate 4 columns in one table into one coulomb

1 vue (au cours des 30 derniers jours)
abdullah al-dulaimi
abdullah al-dulaimi le 30 Oct 2022
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]}

Réponses (2)

Khushboo
Khushboo le 31 Oct 2022
Modifié(e) : Khushboo le 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!

Lei Hou
Lei Hou le 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

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by