필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

When I read a matrix stored in a text file, the values are shuffled about

조회 수: 1 (최근 30일)
laurie
laurie 2015년 3월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
fid = fopen('mat.txt','r');
matrix = fscanf(fid,'%g',[6 4]);
Could someone explain why this happens? or suggest a better method?
The matrix consists of 1's and 0's

답변 (1개)

Image Analyst
Image Analyst 2015년 3월 17일
Try fread() instead of fscanf(). Not sure that's the problem though. Are you sure you're not confusing (x,y) with (row, column)? That's the error most novices make. Remember (row, column) is (y,x) NOT (x,y).
  댓글 수: 2
laurie
laurie 2015년 3월 17일
Matrix in file:
0 1 0 0
1 1 0 0
1 1 1 0
0 1 1 1
0 1 0 1
0 0 0 1
fscanf:
0 0 0 0
1 0 1 1
0 1 1 0
0 1 1 0
1 1 0 0
1 0 1 1
Image Analyst
Image Analyst 2015년 3월 17일
편집: Image Analyst 2015년 3월 17일
If you're still having a problem, attach the file with the paper clip icon. Or why not use dlmread() with a delimiter of space or tab, whichever it is?

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by