Input txt. file of complex numbers
14 views (last 30 days)
I have large data text files from COMSOL that contain multiple rows and columns of complex numbers. I have tried importing them into matlab as the files are quite large, but all the data is presented in a single column. eg:
-12.475000000000005 -1.975 2.5658824311275345E-6+4.421192310257837E-6i -4.688910807327458E-7-9.893058421633841E-8i 5.549150260222212E-6-2.1496631444278723E-5i -2.7187186095082164E-9+1.1189876165621303E-8i
I have tried to include Space as a column delimiter but it gives me the message: "com.mathworks.jmi.MatlabException: Arrays have incompatible sizes for this operation". How can I import this data properly?
Johannes Hougaard on 29 Jun 2021
As far as I can tell you can use the readmatrix function to read the file if you use the 'NumHeaderLines' option for the import.
COMSOL = readmatrix("COMSOL.TXT",'NumHeaderLines',9);