How to concatenate 4 columns in one table into one coulomb
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Khushboo
el 31 de Oct. de 2022
Editada: Khushboo
el 31 de Oct. de 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 comentarios
Lei Hou
el 18 de Nov. de 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 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!