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:
import data problem

Subject: import data problem

From: J G

Date: 20 Dec, 2010 02:53:04

Message: 1 of 2

I would like to import data from a txt file

load myfile.txt

However within this file there are some blank spaces and I'm getting this error message:

??? Error using ==> load
Number of columns on line 44 of ASCII file
C:\MATLAB\myfile.txt
must be the same as previous lines.

Can anyone help?
Thanks.

Subject: import data problem

From: Walter Roberson

Date: 20 Dec, 2010 04:23:57

Message: 2 of 2

On 19/12/10 8:53 PM, J G wrote:
> I would like to import data from a txt file
>
> load myfile.txt
>
> However within this file there are some blank spaces and I'm getting
> this error message:
>
> ??? Error using ==> load
> Number of columns on line 44 of ASCII file
> C:\MATLAB\myfile.txt
> must be the same as previous lines.
>
> Can anyone help?

Yes: don't use load() for that text file. Probably the import wizard
would not do much better either -- though the import wizard might be
able to handle it if there is a fixed field delimiter such as semi-colon
or tab.

textscan might be usable, if the field that contains the blanks is a
fixed width.

If the field that contains the blanks is not a fixed width and if you do
not have a fixed field delimiter, then we need to know more about how
you recognize that you have reached the end of the field that might
contain blanks.

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