Horizontally concatenating two column vectors with a comma

8 vues (au cours des 30 derniers jours)
Jason
Jason le 31 Mar 2017
Commenté : Jason le 31 Mar 2017
Hi, I have an array called Data:
Data=
1.0e+03 *
1.7583 1.4163
1.7493 0.5127
0.1946 1.4305
0.1865 0.5286
0.1963 1.4336
1.7568 1.4186
I want to view these in a multi line edit box. I have tried:
textout=horzcat(num2str(data(:,1),'%0.f'),num2str(data(:,2),'%0.f'))
But this doesn't leave any gap between the two entries
textout =
17581416
1749 513
1951431
187529
1961434
17571419
How can I get the following output:
textout =
1758, 1416
1749, 513
1951, 431
187, 529
196, 1434
1757, 1419

Réponse acceptée

KSSV
KSSV le 31 Mar 2017
data= 1.0e+03 *[1.7583 1.4163
1.7493 0.5127
0.1946 1.4305
0.1865 0.5286
0.1963 1.4336
1.7568 1.4186] ;
strcat(num2str(data(:,1)),',', num2str(data(:,2)))

Plus de réponses (1)

Guillaume
Guillaume le 31 Mar 2017
Modifié(e) : Guillaume le 31 Mar 2017
Assuming a newish version of matlab (>= R2016b)
char(compose('%0.f, %0.f', data))

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by