problem about reading ascii file

Hi I am reading ascii file by fscanf.However with the same code but different number of lines i cannot read the other ascii file. I sent you the code as screenshot.One of them gives me the correct amount of matrix bu the other reads only 1x1 matrix. Please help Regards, Seyfi

댓글 수: 7

Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 20일
Instead of attaching images, just past your code and attach your text file
Walter Roberson
Walter Roberson 2015년 8월 20일
In particular we need your second text file, the one that is not reading properly.
Note: it appears to me that you are forgetting to fclose(fid) when you are done with it. Your "fig" in the 3.png is the file identifier and in the 4.png we can see it has the value 138, which indicates that you must have at least 138 files open, which can become a problem itself.
seyfi girgin
seyfi girgin 2015년 8월 20일
here is the txt file and for this file the code is; clear all close all clc fid=fopen('mcfd_3tec.dat'); fgetl(fid) fgetl(fid) fgetl(fid) fgetl(fid) fgetl(fid) fgetl(fid) fgetl(fid)
A=fscanf(fid,'%e %e %e %e %e',[5 inf]); A
This works.But the differense from the other txt file is,one of them contains 7 rows thats why I wrote 7 times fgetl(fid), other contains 9 rows so I wrote 9 times fgetl(fig).Because of the limit I cannot upload it.
seyfi girgin
seyfi girgin 2015년 8월 20일
I tired with fclose(fid) but again gave me the same result.Why do this code works with a txt file but do not work with another txt file?
Walter Roberson
Walter Roberson 2015년 8월 20일
You could probably zip the second file and attatch the .zip
seyfi girgin
seyfi girgin 2015년 8월 21일
here is the codes and txt files.Only difference between txt files is that you can add 2 more lines under Title=''CFD++....'' as VARIABLES = "X" "Y" which is as mcfdxyden_tec
seyfi girgin
seyfi girgin 2015년 8월 21일
I solved the problem it was all about saving

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

답변 (0개)

카테고리

질문:

2015년 8월 20일

댓글:

2015년 8월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by