假设我有一个复杂的矩阵:
fprintf(fid, [repmat('%.8f\t', 1, size(A, 2)) '\n'], A');
如何将此复杂矩阵打印到txt文件中?我尝试:
// Created by lenovo on 8/27/2017.
//
#ifndef UART_UART_CFG_H
#define UART_UART_CFG_H
#define UART_BaudRate 1200 //9600UL
#define CLK 16
#define UART_Parity NONE
#define UART_TX EN_TX
#define UART_RX EN_RX
#define UART_STARTBITS 1
#define UART_STOPBITS 1
#define UART_DATABITS EightBits
#endif //UART_UART_CFG_H
但它只打印实数。
答案 0 :(得分:2)
您可以分别输出实部和虚部:
fprintf(fid, [repmat('%.8f%+.8fi\t', 1, size(A, 2)) '\n'], ...
[real(reshape(A.', 1, [])); imag(reshape(A.', 1, []))]);