matrix file output problem?
이전 댓글 표시
when i run my code it give the answers start with Y= ... and give the matrix output divided in column (Columns 1 through 14,Columns 15 through 28 and so on) i want the answer to be a matrix file without Y= or columns divided to parts. how to do this? (my output file is txt file) help needed
댓글 수: 8
jim
2014년 10월 20일
Hikaru
2014년 10월 20일
I'm guessing that you're seeing MATLAB displaying the answer in the command window. The answer is one whole matrix, it's just that the command window has limitation in the amount of characters it can display, which is why you saw (Columns 1 through 14,Columns 15 through 28 and so on). To view the matrix, simply click on the variable Y in your workspace. Just a guess, not sure if I understood your question right.
You used function diary to create the text file, but diary is really just whatever that is displayed in your command window (not like in the workspace). If you want the output Y in a text file, use fprinf.
fileID = fopen('output.txt','w')
fprintf(fileID,'%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\r\n',y);
fclose(fileID);
Or if you want the columns to be together, just remove the spaces between %d.
jim
2014년 10월 20일
Hikaru
2014년 10월 20일
I don't really know why, but you are right, y' gives the correct output. And I tested it using your matrix M, I didn't see the mirrored bit.. my output is attached, is it not the same as y?
fileID = fopen('output.txt','w')
fprintf(fileID,'%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\r\n',y');
fclose(fileID);
jim
2014년 10월 20일
채택된 답변
추가 답변 (1개)
MatlabFan
2014년 10월 19일
0 개 추천
I suggest that you rephrase your question, and be more specific about what exactly it is that you are trying to achieve. I don't have any idea of what you need help on, because your question is not well posed. Please, pose your question in a way that gives clear details as to what you want to accomplish; and I'm sure you will get very satisfactory answers, and in a quick turnaround time too.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!