Matlab outputs complex values to .txt files

I encountered a problem today, how to output complex values ​​from matlab to a .txt file. Seeing many methods on the Internet, I think the method is the best to use dlmwrite. The calling format is as follows:

dlmwrite('C:\matlab_datadebug1.txt'', array)

Here arrayrefers to the matrix (array) we want to write. If it arrayis one-dimensional, in order to better view the value, it is recommended to use transpose(array)or array.Toutput, so that each row stores one data, and the data can be clearly identified and viewed.
But the problem that needs to be noted here is that when using matlaboutput data, if the data itself has a decimal part, matlabit will automatically retain significant digits after the decimal point when outputting 4. Therefore, if these data are to be used for further calculations, it is not recommended, because at this time The accuracy has changed.
Matlab output data to txt file
As you can see, the above picture shows a series of decimal values ​​output. Only 4significant digits are reserved after the decimal point . Of course, the significant digits can be changed. The specific method will be explained later.

Note that the array arraycan be a complex number. If it is a complex number, the precision of the real and imaginary parts are both significant digits after the decimal point 4.

The code word is not easy, if you find it useful, please raise your hand to give a like and let me recommend it for more people to see~

Guess you like

Origin blog.csdn.net/u011699626/article/details/112423640