Treatment G-code file
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a G-code file as you can see in the following structure :
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
编辑: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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!