How to convert a .mat file into tab separated .txt file?
187 次查看(过去 30 天)
显示 更早的评论
Hello Friends,
I have a data matrix of real entries. I saved this matrix in MATLAB Workspace as .mat file. I want to convert it to tab separated .txt file. For this I tried the following:
load('myFile.mat')
dlmwrite('myFile.txt', myFile, 'delimiter','\t')
it does create a text file which is in notepad with name myFile.txt, however, this .txt file puts all the elements of the 1st row, 2nd row, 3rd row, etc. in one row. I do not even understand what it does. I just wanted it to remain in the same way as before, but just with tab separated and in .txt.
Though when I type the following command, it shows tab separated columns as I wanted in Command Window:
type('myFile.txt')
Please advise!
1 个评论
Stephen23
2015-3-30
The problem is Notepad does not interpret newline-only files as newlines, but requires carriage return+newline (the PC standard). You can read more about newline standards: note that Notepad does not interpret non-PC newlines, but that Wordpad does.
采纳的回答
hello_world
2015-2-24
编辑:hello_world
2015-3-30
7 个评论
Walter Roberson
2019-3-1
Labels = ECGData.Labels;
Data = ECGData.Data;
T = table(Labels, Data);
writetable(T, 'ECGData.csv', 'WriteVariableNames', false);
This will create a .csv file in which the first column is the text label, and the remaining 65536 columns are the numeric values.
Note that this .csv file cannot be loaded into Excel, as Excel has a limit of 16384 columns.
If you wanted to get something that could be loaded into Excel, you will need to describe the format that you want for your text file.
更多回答(2 个)
Neha Chaudhary
2018-4-2
编辑:Walter Roberson
2018-4-2
Nr=input('Enter no of antennas (Nt = Nr):');
Nt=Nr;
Sigma=input('0.1:1');
Pt=input('enter total power')
X=(2*randi(4,[Nt,1])-5)+i*(2*randi(4,[Nt,1])-5)%input signal*16QAM
H=(randn(Nt,Nr)+i*randn(Nt,Nr))/sqrt(2)%channel matrix H
N=(Sigma/sqrt(2))*(randn(Nt,1)+i*randn(Nt,1));%Noise matrix with variance sigma
Y=H*X+N;%output
G=inv(H'*H+Nt/Pt*eye(Nt))*H'%Pseudo inverse matrix
z=G*Y;%estimated input
Z_cap=1+2*floor(real(z)/2)+i*(1+2*floor(imag(z)/2))%slise(z)
Z_cap-X
Neha Chaudhary
2018-4-2
编辑:Walter Roberson
2018-4-2
X=(2*randi(4,[Nt,1])-5)+i*(2*randi(4,[Nt,1])-5)%input signal*16QAM
dlmwrite('myFile.txt', myFile, 'delimiter','\t','newline','pc')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!