필터 지우기
필터 지우기

read a line frome file

조회 수: 2 (최근 30일)
zina ben
zina ben 2012년 1월 14일
I have a data.m file with the following data:
1
2 3 5
3 3 2
8
9
i have use the following to load file and its work
load('data.m');
now i want to read just the 1st row, 3rd row and the 4th row
please help me, i need your help
  댓글 수: 2
Jan
Jan 2012년 1월 14일
Please do not post three threads for one question. You can edit a question to improve it. I recommend to delete the older threads.
Walter Roberson
Walter Roberson 2012년 1월 14일
Duplicate is at http://www.mathworks.com/matlabcentral/answers/26098-read-data-from-m-file

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

채택된 답변

Jan
Jan 2012년 1월 14일
M-files are usually text files, which contain Matlab commands. It is a bad idea to fill an M-file with some numbers only. Most of all load is not sufficient to read your data file. Better use fopen and fscanf and skip the lines, which you want to ignore.
See also:
doc fscanf
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 1월 14일
http://www.mathworks.com/help/techdoc/ref/fopen.html
http://www.mathworks.com/help/techdoc/ref/fscanf.html
http://www.mathworks.com/help/techdoc/ref/fclose.html
Ingo
Ingo 2012년 1월 14일
In addition:
You could also use csv files (comma-separated) and use readcsv and so on. Those Matlab functions already come with the extra of only reading certain rows/columns/areas.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by