Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
I have a problem when using the matlab. please help me.
조회 수: 1 (최근 30일)
이전 댓글 표시
hello~!!
I have a problem when I use matlab. I want to skip the line that have specific characters.
examples : aaaaaaaaaaa.txt
dafdasdfasdfsdfa
****ddddddddddd
1.2.2.23.4.5.
3.3.45.t.
.g.g.f.g.h.
* dfdfd
**xddddddddddddd
I want to read the text without * rows.
please help me.
댓글 수: 0
답변 (1개)
Harish Ramachandran
2017년 12월 28일
For a trivial implementation,
You can open the file, scan each line for the character " * " (using 'contains' function) and proceed to display the lines with no " * "
file = fopen('aaaaaaaaaaa.txt');
line = fgetl(file);
while ischar(line)
if contains(line,'*') == 0
disp(line)
end
line = fgetl(file);
end
fclose(file);
Based on the input you provided, the output of the code will be:
dafdasdfasdfsdfa
1.2.2.23.4.5.
3.3.45.t.
.g.g.f.g.h.
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!