How to import data from a .txt file with semicolons
10 views (last 30 days)
Show older comments
Stefano Morese
on 3 May 2022
Commented: Stefano Morese
on 14 Jun 2022
Hi everyone! I'm trying to import data from a .txt file containing separate numbers divided by semicolons.
1;0,1254;0,1204;0,09992;286400;162400;52400;0,00003035;1,000;24,68;
2;0,1891;0,1841;0,1206;318500;82590;52360;0,00003666;1,000;24,68;
3;0,2525;0,2475;0,1455;288900;106900;49030;0,00004724;1,000;24,68;
4;0,3159;0,3110;0,1756;158800;199900;40640;0,00006878;1,000;24,69;
5;0,3796;0,3746;0,2119;299400;139600;52580;0,00006415;1,000;24,69;
6;0,4431;0,4382;0,2558;307700;108300;51910;0,00007841;1,000;24,68;
7;0,5066;0,5016;0,3087;311800;58440;50490;0,00009730;1,000;24,67;
8;0,5697;0,5647;0,3725;338800;111200;56750;0,0001045;1,000;24,68;
9;0,6331;0,6281;0,4495;329000;119800;55730;0,0001284;1,000;24,67;
10;0,6970;0,6921;0,5425;347000;64970;56190;0,0001537;1,000;24,68;
11;0,7601;0,7551;0,6546;347900;81310;56860;0,0001832;1,000;24,67;
12;0,8226;0,8177;0,7900;362400;78730;59020;0,0002130;1,000;24,67;
13;0,8864;0,8815;0,9534;385400;78650;62610;0,0002423;1,000;24,67;
14;0,9488;0,9439;1,151;382100;88800;62430;0,0002933;1,000;24,67;
15;1,012;1,007;1,388;376300;90700;61600;0,0003587;1,000;24,67;
16;1,075;1,070;1,676;366400;79970;59690;0,0004467;1,000;24,67;
17;1,139;1,134;2,022;399300;96500;65380;0,0004922;1,000;24,68;
18;1,202;1,197;2,440;389800;90600;63690;0,0006098;1,000;24,68;
19;1,264;1,259;2,945;389000;94200;63710;0,0007357;1,000;24,68;
20;1,327;1,323;3,554;397100;89180;64770;0,0008732;1,000;24,68;
21;1,390;1,385;4,289;399300;86260;65020;0,001050;1,000;24,68;
22;1,453;1,448;5,175;405700;89590;66120;0,001246;1,000;24,67;
23;1,516;1,511;6,246;397000;90330;64800;0,001534;1,000;24,68;
24;1,584;1,579;7,537;405400;87420;66010;0,001817;1,000;24,68;
25;1,647;1,642;9,096;410900;85440;66800;0,002167;1,000;24,68;
26;1,710;1,705;10,98;414200;86040;67320;0,002595;1,000;24,68;
27;1,773;1,768;13,25;414300;87440;67390;0,003128;1,000;24,68;
28;1,835;1,831;15,99;416600;86070;67700;0,003758;1,000;24,69;
29;1,898;1,893;19,29;417400;85800;67820;0,004527;1,000;24,68;
30;1,961;1,956;23,28;416800;89200;67850;0,005461;1,000;24,68;
31;2,024;2,019;28,10;415900;87820;67650;0,006610;1,000;24,68;
32;2,086;2,081;33,91;413500;87900;67280;0,008021;1,000;24,68;
33;2,149;2,144;40,92;407400;89910;66400;0,009808;1,000;24,67;
34;2,212;2,207;49,38;399600;90260;65200;0,01205;1,000;24,66;
35;2,276;2,271;59,59;387600;91300;63370;0,01497;1,000;24,67;
36;2,339;2,334;71,91;369800;92470;60660;0,01887;1,000;24,66;
37;2,403;2,398;86,78;344500;93100;56800;0,02432;1,000;24,66;
38;2,465;2,460;104,7;308900;92810;51330;0,03247;1,000;24,66;
39;2,529;2,524;126,4;261500;89990;44020;0,04570;1,000;24,65;
40;2,592;2,587;152,5;198700;81290;34170;0,07106;1,000;24,65;
41;2,655;2,650;184,1;111900;59340;20160;0,1454;1,000;24,65;
42;2,719;2,714;230,5;99,26;274,3;46,43;79,01;1,000;24,66;
43;2,783;2,778;239,2;4,852;55,10;8,803;432,4;1,000;24,66;
44;2,846;2,841;248,4;4,301;30,28;4,868;812,2;1,000;24,67;
45;2,910;2,905;276,8;3,175;25,17;4,038;1091;1,000;24,67;
46;2,972;2,968;311,8;2,313;21,66;3,467;1432;1,000;24,68;
47;3,035;3,030;354,8;1,725;18,97;3,032;1863;1,000;24,67;
48;3,099;3,094;399,9;1,021;16,61;2,649;2402;1,000;24,68;
49;3,163;3,158;465,3;0,7125;15,01;2,392;3096;1,000;24,68;
50;3,225;3,220;509,1;0,05450;12,82;2,040;3971;1,000;24,68;
I would like to import a 50x10 matrix from that; can someone help me?
Thank you very much in advance!
0 Comments
Accepted Answer
Stephen23
on 3 May 2022
Because you did not upload a sample file I had to create my own (attached).
format short G
mat = readmatrix('test.txt', 'Delimiter',';', 'DecimalSeparator',',')
More Answers (0)
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!