Thread Subject: problems using textread

Subject: problems using textread

From: Matthew

Date: 18 Nov, 2008 20:48:02

Message: 1 of 5

i am trying to read in the 3rd value of the 1st numerical line 0.000 0.6149 0.00834 ........ of the file below using textread. however i am having a lot of problems and it just will not read the line i want. it is the first time i have used this type of text scanning read in method and it is starting to annoy me. i want to read the value in exactly as is shown in the file below then assign it to the variable Cd.


       XFOIL Version 6.94
  
 Calculated polar for: test airfoil
  
 1 1 Reynolds number fixed Mach number fixed
  
 xtrf = 0.500 (top) 0.500 (bottom)
 Mach = 0.100 Re = 1.000 e 6 Ncrit = 9.000
  
  alpha CL CD CDp CM Top_Xtr Bot_Xtr
 ------- -------- --------- --------- -------- ------- -------
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
   0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997



any help on this matter who be greatly appreciated as it does not seem to matter how i construct my code i just cannot get it to work :(

Subject: problems using textread

From: Vadim Teverovsky

Date: 18 Nov, 2008 20:56:12

Message: 2 of 5

Two suggestions:
1) Use textscan instead of textread, it is the newer more full-featured
function.
2) Please post your code, otherwise its difficult to help. You likely need
to skip some number of headerlines, and then should be able to read the
numeric data.
"Matthew " <men5mjr@leeds.ac.uk> wrote in message
news:gfv9m2$968$1@fred.mathworks.com...
>i am trying to read in the 3rd value of the 1st numerical line 0.000 0.6149
>0.00834 ........ of the file below using textread. however i am having a
>lot of problems and it just will not read the line i want. it is the first
>time i have used this type of text scanning read in method and it is
>starting to annoy me. i want to read the value in exactly as is shown in
>the file below then assign it to the variable Cd.
>
>
> XFOIL Version 6.94
>
> Calculated polar for: test airfoil
>
> 1 1 Reynolds number fixed Mach number fixed
>
> xtrf = 0.500 (top) 0.500 (bottom)
> Mach = 0.100 Re = 1.000 e 6 Ncrit = 9.000
>
> alpha CL CD CDp CM Top_Xtr Bot_Xtr
> ------- -------- --------- --------- -------- ------- -------
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
>
>
>
> any help on this matter who be greatly appreciated as it does not seem to
> matter how i construct my code i just cannot get it to work :(
>
>

Subject: problems using textread

From: Luca Zanotti Fragonara

Date: 18 Nov, 2008 20:57:02

Message: 3 of 5

fin=fopen('filename','rt')
A=textread(fin,'%f %f %f %f %f %f %f','endofline','\n','Headerlines',number);
fclose(fin);
where number is the number of the row where you want to start to read the file.
in A{3} you have your Cd, so
CD=A{3}(:,1);

"Matthew " <men5mjr@leeds.ac.uk> wrote in message <gfv9m2$968$1@fred.mathworks.com>...
> i am trying to read in the 3rd value of the 1st numerical line 0.000 0.6149 0.00834 ........ of the file below using textread. however i am having a lot of problems and it just will not read the line i want. it is the first time i have used this type of text scanning read in method and it is starting to annoy me. i want to read the value in exactly as is shown in the file below then assign it to the variable Cd.
>
>
> XFOIL Version 6.94
>
> Calculated polar for: test airfoil
>
> 1 1 Reynolds number fixed Mach number fixed
>
> xtrf = 0.500 (top) 0.500 (bottom)
> Mach = 0.100 Re = 1.000 e 6 Ncrit = 9.000
>
> alpha CL CD CDp CM Top_Xtr Bot_Xtr
> ------- -------- --------- --------- -------- ------- -------
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
> 0.000 0.6149 0.00834 0.00179 -0.1316 0.5000 0.1997
>
>
>
> any help on this matter who be greatly appreciated as it does not seem to matter how i construct my code i just cannot get it to work :(
>

Subject: problems using textread

From: Luca Zanotti Fragonara

Date: 18 Nov, 2008 21:40:20

Message: 4 of 5

Sorry, I've posted 2 times, and this is the third. But I've posted a wrong code. I've written textread, while I was thinking at textscan. So the correct code is:
fin=fopen('filename','rt')
A=textscan(fin,'%f %f %f %f %f %f %f','endofline','\n','Headerlines',number);
fclose(fin);
CD=A{3}(:,1);

"Luca Zanotti Fragonara" <Luca_Zanotti@libero.it> wrote in message <gfva6u$grj$1@fred.mathworks.com>...
> fin=fopen('filename','rt')
> A=textread(fin,'%f %f %f %f %f %f %f','endofline','\n','Headerlines',number);
> fclose(fin);
> where number is the number of the row where you want to start to read the file.
> in A{3} you have your Cd, so
> CD=A{3}(:,1);
>

Subject: problems using textread

From: Matthew

Date: 19 Nov, 2008 15:52:02

Message: 5 of 5

Luca,

thank you, it was a comn=bination of the headerlines and the %f's i was using i think??? but it is working fine now so thanks a lot!!

Matthew


"Luca Zanotti Fragonara" <Luca_Zanotti@libero.it> wrote in message <gfvco4$ke0$1@fred.mathworks.com>...
> Sorry, I've posted 2 times, and this is the third. But I've posted a wrong code. I've written textread, while I was thinking at textscan. So the correct code is:
> fin=fopen('filename','rt')
> A=textscan(fin,'%f %f %f %f %f %f %f','endofline','\n','Headerlines',number);
> fclose(fin);
> CD=A{3}(:,1);
>
> "Luca Zanotti Fragonara" <Luca_Zanotti@libero.it> wrote in message <gfva6u$grj$1@fred.mathworks.com>...
> > fin=fopen('filename','rt')
> > A=textread(fin,'%f %f %f %f %f %f %f','endofline','\n','Headerlines',number);
> > fclose(fin);
> > where number is the number of the row where you want to start to read the file.
> > in A{3} you have your Cd, so
> > CD=A{3}(:,1);
> >
>

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
textread Sprinceana 10 Sep, 2009 10:31:56
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com