to make string file same size by adding missing string

조회 수: 2 (최근 30일)
azim
azim 2017년 5월 30일

hi, i have a file containing string information as following: GERMANY, 17, 19, 12, 16, 19, 13 FRANCE, 20, 23, 19, 12, 17, 18 INDIA, 7, 5, 11, 12, 13, 10 CROATIA, 8 , 9, 13, 11, 14, 11 USA, 30, 31, 25, 26, 23, 27

i transfer that to matlab now i have 70 files like this from which i have to read information but some file have information like this in which some countries are missing: GERMANY, 174, 219, 312, 216, 419, 713 INDIA, 77, 54, 110, 132, 133, 107 CROATIA, 88 , 95, 134, 117, 146, 119 USA, 230, 310, 325, 268, 237, 276 or like this GERMANY, 117, 139, 112, 136, 159, 113 FRANCE, 120,123, 139, 12, 17, 18 INDIA, 7, 5, 11, 12, 13, 10 USA, 30, 31, 25, 26, 23, 27

what i want is the countries which are missing in the string should be added at its appropriate place followed by zeros. so the final should look like this: GERMANY, 174, 219, 312, 216, 419, 713 FRANCE, 0, 0, 0, 0, 0, 0 INDIA, 77, 54, 110, 132, 133, 107 CROATIA, 88 , 95, 134, 117, 146, 119 USA, 230, 310, 325, 268, 237, 276 or like this for the second example above GERMANY, 117, 139, 112, 136, 159, 113 FRANCE, 120,123, 139, 12, 17, 18 INDIA, 7, 5, 11, 12, 13, 10 CROATIA, 0, 0, 0, 0, 0, 0 USA, 30, 31, 25, 26, 23, 27

the number of countries are 5 but some pages have 3 countries and most have 4 and even some have 2 countries. i want that the countries to be listed in the same order as the first list on the top and number of the missing countries to be zeroes. and to just inform all of it is string variable. please help on this matter cause i can't wrap my head around this problem. thanks, azim

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by