Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Reading data from a text file.

Subject: Reading data from a text file.

From: Danny

Date: 20 Feb, 2010 02:18:05

Message: 1 of 2

I know this is simple but I have been trying to work out the commands using help for ages now.

I have various text files of varying lengths which contain a selection of words and numbers delimited by a ','. I want matlab to read a word, do an action based on that word says then read the next word, repeating untill there are no more words.

The closest I have got is by opening the file and calling it fid then doing

A = textscan(fid, '%s','delimiter',',');

But that puts all the data into 1 cell in A. Please Please Please help me out here before I go insane! It seems so simple compared to everything else I am getting to work lol.

Thanks, Danny.

Subject: Reading data from a text file.

From: Sadik

Date: 20 Feb, 2010 04:03:05

Message: 2 of 2

Hi Danny,

I guess it would help others if you could post here a few sample lines from one of the files you would like to read.

Best.



"Danny " <danny.nicholls.09@ucl.ac.uk> wrote in message <hlngot$14b$1@fred.mathworks.com>...
> I know this is simple but I have been trying to work out the commands using help for ages now.
>
> I have various text files of varying lengths which contain a selection of words and numbers delimited by a ','. I want matlab to read a word, do an action based on that word says then read the next word, repeating untill there are no more words.
>
> The closest I have got is by opening the file and calling it fid then doing
>
> A = textscan(fid, '%s','delimiter',',');
>
> But that puts all the data into 1 cell in A. Please Please Please help me out here before I go insane! It seems so simple compared to everything else I am getting to work lol.
>
> Thanks, Danny.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us