Treatment G-code file
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I have a G-code file as you can see in the following structure :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/312050/image.png)
How I can with matlab to find the number of rows which carry the character of Z and to copy the instructions between two defined rows in another file .txt.
Thank you
댓글 수: 2
Rik
2020년 6월 8일
It sounds like you can just read this file as text and use contains to look for a Z.
채택된 답변
Rik
2020년 6월 8일
편집: Rik
2020년 6월 8일
str = fileread('gcode.txt');
cell_str=strsplit(str,'\n')
character = 'Z';
TF = contains(cell_str,character);
line_num=find(TF);
댓글 수: 6
Rik
2020년 6월 8일
You're welcome. If you feel my answer solved your question, please mark it as accepted answer. If not, feel free to comment with your remaining issues.
추가 답변 (1개)
Bjorn Gustavsson
2020년 6월 8일
Maybe the easiest way it to loop through the text line-by-line and check if it contains the character 'Z' using strfind or findstr. Then it should be perfectly straightforward to keep the indices where you find your Zs.
HTH
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!