How to remove comma from numerical data

20 views (last 30 days)
Dun
Dun on 11 Oct 2022
Answered: Les Beckham on 11 Oct 2022
I have the following raw data typed into Matlab (see below). How would I filter it so that the commas are replaced, while preserving their numerical nature?
X = [51,051 4,642,245 7,584 3,840 21,949 7,948 6,299 14,476 4,348;
60,912 5,463 51 13,078 18,659 1,295 186 4,316 773,048;
1,356 807 6,237 7,502 29,417 22,574 10,976 18,685 5,376;
6,349 66,984 32,273 41,421 24,473 24,179 1,331,475 2,957,476 157,776;
23,430 46,610 197,257 270,576 158,444 294,013 203,822 656,977 258,002;
915 2 644 6,547 14,239 13,239 16,774 135,234 4,338;
10,008 14,014 6,190 18,763 271,555 22,966 60,202 29,237 49,248;
2,095 853,972 155 1,646 81,880 155,467 433,725 36,867 58,480;
257,250 22,125 3,507 2,248 1,943 9,482 22,262 146,957 38,302;
35,526 55,039 91,589 553,818 571,200 215,656 584,866 287,247 75,022;
8,188 2,852,653 10,008 18,953 82,018 17,728 14,014 18,763 6,190;
5,585 8,074 16,066 16,611 42,319 18,730 26,000 51,306 107,018;
9,026 4,441 14,555 5,224 15,074 302,868 58,982 111,848 122,527;
1,707,292 1,041,752 1,045,988 1,932,777 1,656,384 935,452 3,016,318
2,783,875 2,012,255;
18,144 782 1,299 11,345 44,307 29,577 52,224 30,849 78,174;
25,904 1,916,861 1,261 1,840 5,215 1,798 9,867 3,581 542,288;
1,434 1,354 66 89,963 4,681 26,146 1,333 44,042 587;
216,853 897,002 211,224 67,253 123,759 531,051 412,581 466,689 533,238;
10,036 17,488 3,362 13,847 18,656 3,342 6,972 3,455 29,719]

Answers (1)

Les Beckham
Les Beckham on 11 Oct 2022
Copy this text and paste it into a text editor. Then search and replace all of the commas with nothing. Then run that modified text instead of the original. Be careful of any "soft wrapping" of the lines of text.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by