How to convert a .mat file into tab separated .txt file?
200 ビュー (過去 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!