Q:

File format of 2d array octave

I have the following 2d array:
1 2 3
4 5 6
7 8 9

stored in a text file in format: [1 2 3; 4 5 6; 7 8 9;].  However when I try to load this file and save to a variable using:
    a = load('data.txt'), it gives me following error:

error: load: unable to determine file format of 'data.txt'

Any suggestion on this would be nice.  Thanks. 

A:

load only handles ASCII data if it's in the format shown in the first part of your post.  
data.txt
1 2 3
4 5 6
7 8 9

And read it using:
data = load('data.txt', '-ascii');

If your data is stored as a formatted string rather than the ASCII matrix shown above, you'll have to read the file in a string and then use str2num to convert it to a 2D array.  
fid = fopen('data.txt', 'r');
data = str2num(fread(fid, '*char').'); 
fclose(fid);

In the future, I would recommend storing matrices as ASCII as shown in the top part of the post

