MATLAB Answers


How to Import unformatted text data?

Asked by Maddila
on 4 Oct 2012

Below I have attached a text file , how to read and separate the values



Show 1 older comment

Are you sure that these data are not concerned by the export restrictions of mass destruction weapons? I got troubles already when I've posted an 128-bit AES encryption in the FEX...

Would our assistence support killing of human in any nation for any reasons?

CAE is a well-known defense contractor. So, yeah, probably.

No ,,This is just reference text file,,i have to program it mr Jan Simon,,

Log in to comment.

1 Answer

Answer by Matt Kindig on 4 Oct 2012
 Accepted Answer

Hi Maddila,

This looks like a rather non-uniform format, so your best bet might be to read in the full file, and then separate it out using regexp. It looks like splitting by square brackets might do the trick. Something like this:

str = fileread('your/file/name');    %read in file in full
parts = regexp(str, '\[|\]', 'split');  %split by brackets
%then you can extract information from the individual split out sections.


Log in to comment.

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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!