Readin a txt file and exporting the data in a matrix.
    6 次查看(过去 30 天)
  
       显示 更早的评论
    
I need to exporst data from a txt. file in to mathlab. The numbers in txt. file are all ready in a matrix formation and i just need to read them in the right way. Note that the numbers are some what large. The other problem that i have is that some numbers are displaying like 5,38470670569894e-006 and i don 't know how to read the properly in matrix. The whole matrx in txt. looks like this:
0,001966941955184562	-0,003911512580972464	0,00196164813178966
 0,001966941955184562	-0,003911512580972464	0,00196164813178966
 0,002577327392424367	-0,003881618060113118	0,001321240553858325
 0,003104487507226005	-0,003743335025340043	0,000655344148882383
 0,003463648846379058	-0,003442060440921823	-6,899788122126903e-006
 0,003766180779081077	-0,003084873825043694	-0,0006684846048228966
 0,003904885945573184	-0,002559912110221542	-0,001333433616451176
 0,003934934977298256	-0,001952111878076424	-0,001973473347759163
 0,003905486096653731	-0,001314829321774319	-0,002584322588132094
 0,003767358509522823	-0,0006529690917697279	-0,003111859109363536
 0,003464985497078341	5,38470670569894e-006	-0,003470922583919695
 0,003106816885531419	0,0006633761522620112	-0,003773810469032729
 0,002579929597948367	0,001324024272730192	-0,003911300486504994
 0,001970058714798917	0,001960763452954201	-0,003941156856031188
 0,001330836839789801	0,002568328282739562	-0,003911653438410438
 0,0006668036126518278	0,00309283850926659	-0,003773381208410974
 5,9464362119452e-006	0,003449577990228116	-0,003471092606754313
 -0,0006555661244248223	0,003750568084037704	-0,003112348148352735
 -0,001320779285360738	0,003887961026460433	-0,002584947069810056
 -0,001960979642474189	0,003917270076665622	-0,001974125585754281
 -0,00257143584067414	0,003887200872328649	-0,001333484870813462
 -0,003098034960566031	0,00374829266150665	-0,0006675364675250792
 -0,003456406220448119	0,003445844536245728	-4,946236053912992e-006
0 个评论
回答(1 个)
  Karim
      
 2023-1-4
        
      编辑:Karim
      
 2023-1-4
  
      you can use the readmatrix function, remember to se the decimal seperator to a comma for you data
% 'format long' is only used to print more decimal number to the screen
% you don't need to use this in your code
format long
matrix = readmatrix( 'matrix_values.txt' ,"DecimalSeparator",",")
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

