필터 지우기
필터 지우기

How to write multiple txt files from workspace matrix?

조회 수: 1 (최근 30일)
Eduardo Ortiz
Eduardo Ortiz 2014년 3월 31일
댓글: Peranantham Uruthiran 2019년 1월 30일
Hi,
I'm trying to save multiple .txt files from one single matrix on workspace ('My_matrix'). My_matrix has 480 lines and 116 columns. I'd like to have 116 .txt files, each one containing two columns, the first column for all the 116 files is the same [1,2,...,480] and the second column is the first, second,...,116th column of My_matrix.
Thank you in advance for your kind attention.
Eduardo O.

채택된 답변

Marta Salas
Marta Salas 2014년 4월 1일
X= 1:size(My_matrix,1);
for it=1:size(My_matrix,2)
filename = ['Mytext' num2str(it) '.txt'];
data = [X' My_matrix(:,it)];
dlmwrite(filename,data,'delimiter','\t','precision',3)
end
  댓글 수: 2
Eduardo Ortiz
Eduardo Ortiz 2014년 4월 1일
Thank you very much Marta!
It worked perfect!
:)
Peranantham Uruthiran
Peranantham Uruthiran 2019년 1월 30일
Thank you very much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by