sscanf not working for text on multiple lines.
이전 댓글 표시
I'm trying to read text from a file and put it into various collums. It works when I use the following txt and script:
My txt file looks like:
{co-ordinates 1.5 2.5 4.8 weighting 11.713}{co-ordinates 2.5 2.8 1.7 weighting 21.4}{co-ordinates 1.5 2.5 4.8 weighting 11.7}
My code looks like:
fopen practice2.txt
str = fileread('practice2.txt')
mat = sscanf(str,'{co-ordinates%f%f%f weighting%f}',[4,Inf]).'
mat =
1.5000 2.5000 4.8000 11.7130
2.5000 2.8000 1.7000 21.4000
1.5000 2.5000 4.8000 11.7000
Now im trying to use a different txt file that looks like this:
{
co-ordinates 102.10 93.30 128.50
weighting 1.000000}
{
co-ordinates 99.60 98.50 124.00
weighting 0.622901
}
and now all of a sudden the code doesn't work at all!? Any idea why it's no longer working and how to fix it? Thanks!
댓글 수: 2
Guillaume
2020년 3월 31일
Can you attach to your question an example file
Hannah Taylor
2020년 3월 31일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!