Hello,
I am trying to write a matrix 'A' to a text file. I would like the data written to file like this:
A =
2 0 2 1 2 0
2 2 2 1 0 0
1 2 2 0 0 2
The code given below does not contain the 'A = '. How can I also include the 'A = ' to be written to the file also? Thanks for your help and time.
Here is the code that I have so far:
%%Generation of Random 3 x 6 Matrix
A = randi([0,2],3,6);
dlmwrite('myFile.txt',A,'delimiter','\t')

댓글 수: 4

Walter Roberson
Walter Roberson 2016년 3월 7일
편집: Walter Roberson 2016년 3월 7일
Where are the tabs to appear on the "A =" line and on the empty line after that? Is there to be a tab before the first number on each line?
monkey_matlab
monkey_matlab 2016년 3월 7일
Hello,
There should be a tab before the first number on each line.
Walter Roberson
Walter Roberson 2016년 3월 7일
What should be the tabs on the 'A =' line and the visually empty line after that?
monkey_matlab
monkey_matlab 2016년 3월 7일
편집: monkey_matlab 2016년 3월 7일
Can it be saved like:
A =
\newline
matrix
I am not sure how to answer your question. I would like the constant and matrix be saved bascially the way it is displayed in Matlab:
Thanks for your help and time!

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

답변 (1개)

Walter Roberson
Walter Roberson 2016년 3월 7일

0 개 추천

output = evalc(A);
fid = fopen('myFile.txt', 'wt');
fwrite(fid, output);
fclose(fid);

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

태그

질문:

2016년 3월 7일

답변:

2016년 3월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by