how to use a txt-file in m-file?

yang qun

New Member
i can use the basic tools in matlab,and write small programs :?
now i have a huge txt-file of data,i dont know how to make it into a m-file
:?

could anybody help me :?: :!:
 
import it
 
thanx

Thank you , but should i import it number by number?
Sorry to bother you , i have been seeking any book i can get
they didnt give the practical way


[/img]
 
All you need is to read the documentation. They have a category for File I/O functions.

**broken link removed**
 
Re: thanx

yang qun said:
Thank you , but should i import it number by number?
Sorry to bother you , i have been seeking any book i can get
they didnt give the practical way


[/img]

under the FILE menu is an IMPORT DATE option just use that

fialing that use the "dlmread" function
 
yeah

i greatly appreciate your timely help!!
now i know it
thank you very much
 
me again

it's me again
i create a extended .txt file in which i type one number 5
command code
M=dlmread('data.txt','dlm')
it give information
error dlm must be a single character
what dose it mean?


i am confused
 
it means you are trying to read a DLM-limited-file

ie

1dlm2
3dlm4
5dlm6


two way around it


1)

dlm = ','
M=dlmread('data.txt',dlm)

note no quotes around dlm

2)

M=dlmread('data.txt',',')
 
dose it can compute 1000*100 matrix?
maybe my edition is a little old
 
yup it can
one row is depicted by a line in the file
one colomn is depicted by a delimiter separation

1,2,3,4,5,6,...........
1001,1002,1003,....
2001,2002,2003,...

would be imported as a 1000x100 matrix

make sure you are using the correct delimiter
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…