Write matrix to a Tab-Delimited text file

조회 수: 69 (최근 30일)
Jake
Jake 2020년 3월 16일
편집: dpb 2020년 3월 17일
Hello again,
I'm reading certain data from a csv file and I want to write some of the columns of the csv file to a tab delimited text file. So far, I have this;
[n, t, r] = xlsread('file.csv');
A = r(:,1);
L = r(:,5);
B = r(:,6);
M = [A, L, B];
And M is a 10×3 cell array. And it only contains numeric data.
I want to export this data to a tab delimited text file. Since I'm using MATLAB R2017a, I can't use writecell.
Any recommendations, documentations to refer of leads?
Thanks in advance!

채택된 답변

Walter Roberson
Walter Roberson 2020년 3월 16일
cell2mat(M) after which you can dlmwrite() with tab delimiter.
  댓글 수: 1
Jake
Jake 2020년 3월 16일
Worked without a problem. Thanks, Walter.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2020년 3월 16일
  1. If are only numeric values in those three columns, then why not use the numeric return values from n instead? Depending on the structure of the spreadsheet, the column numbers may not be 1,5,6, but pick the ones needed instead.
  2. Use dlmwrite('youroutputfile.dat',cell2mat(M),'\t');
  댓글 수: 3
dpb
dpb 2020년 3월 16일
편집: dpb 2020년 3월 17일
xlsread will return only numeric columns in the first return argument w/o any text...
Jake
Jake 2020년 3월 17일
That makes more sense now! I will try this to simplify things. Thank you!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by