Put Strings in a column
Mostra commenti meno recenti
Hello,
I am trying to make a table like the following code.
But when I type my code, countries in each column could not be on the same vertical line like this. Specifically, I have to adjust each time I type a country to make sure for example, 1.Algeria and 9. ChinaHK,...are on the same vertical line, especially 1. and 9. are on exactly the same vertical line.
Could any one please show me how to make them on a vertical line (how to make a column of strings) without using space or tab in the keyboard to adjust?
Thank you,
Countries=[ '1.ALGERIA '; '2.ARGENTINA '; '3.AUSTRALIA '; '4.AUSTRIA '; '5.BELUXNE ';'6.BRAZIL '; '7.CANADA '; '8.CHILE ';
'9.CHINAHK '; '10.COLOMBIA '; '11.DENMARK '; '12.EGYPT '; '13.FINLAND ';'14.FRANCE '; '15.GERMANY '; '16.GREECE ';
'17.INDIA '; '18.INMYSGTH '; '19.IRELAND '; '20.ISRAEL '; '21.ITALY ';'22.JAPAN '; '23.KOREA '; '24.MEXICO ';
'25.NEWZEALAND '; '26.NORWAY '; '27.PAKISTAN '; '28.PERU '; '29.PHILIPPINES ';'30.PORTUGAL '; '31.RUSSIA '; '32.SOUTHAFRICA ';
'33.SPAIN '; '34.SWEDEN '; '35.SWITZERLAND '; '36.TURKEY '; '37.UK ';'38.US '; '39.VENEZUELA '; '40.ROW ']
Risposte (2)
Hi,
I think I would create a separate column for each of the countries you want stacked underneath each other vertically, and then save these as a table at the end. Something like this;
Countries1 = {'1.Algeria';'9.ChinaHK';'17.India'}
Countries2 = {'2.Argentina';'10.Columbia';'18.Inmysgth'}
Countries3 = {'3.Australia';'11.Denmark';'19.Ireland'}
Countries = table(Countries1,Countries2,Countries3)
1 Commento
heidi pham
il 31 Ott 2018
First convert to a cell array (you must use curly brackets). That will result in a single column. Then use reshape() and transpose the array to get exactly what you want.
Countries={ '1.ALGERIA '; '2.ARGENTINA '; '3.AUSTRALIA '; '4.AUSTRIA '; '5.BELUXNE ';'6.BRAZIL '; '7.CANADA '; '8.CHILE ';
'9.CHINAHK '; '10.COLOMBIA '; '11.DENMARK '; '12.EGYPT '; '13.FINLAND ';'14.FRANCE '; '15.GERMANY '; '16.GREECE ';
'17.INDIA '; '18.INMYSGTH '; '19.IRELAND '; '20.ISRAEL '; '21.ITALY ';'22.JAPAN '; '23.KOREA '; '24.MEXICO ';
'25.NEWZEALAND '; '26.NORWAY '; '27.PAKISTAN '; '28.PERU '; '29.PHILIPPINES ';'30.PORTUGAL '; '31.RUSSIA '; '32.SOUTHAFRICA ';
'33.SPAIN '; '34.SWEDEN '; '35.SWITZERLAND '; '36.TURKEY '; '37.UK ';'38.US '; '39.VENEZUELA '; '40.ROW '};
CountriesArray = reshape(Countries, 8, 5)';

Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!