How do I import ASCII data into an M-file?

I used to be able to simply have a line that said
load filename
Now that generates the error
??? Attempt to execute SCRIPT EGPScript as a function:
C:\Users\egp\Desktop\EGPScript.m
I have tried everything, including
S = load('filename', '-ascii')
S = load('filename');
load 'filename' x y
load filename
load 'filename'
I've read all of the documentation. I have even had the Import Wizard generate a function
function importfile(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Auto-generated by MATLAB on 13-Mar-2011 13:34:59
% Import the file
rawData1 = importdata(fileToRead1);
but that generates the same error message.
By the way, my file is very simple, it looks like this
0.000000 0.000000
0.000244 0.000000
. .
. .
. .
0.999756 0.000000
1.000000 0.000000
Thanks,
- EGP

1 Comment

I can't reproduce your problem. Is your file name EGPScript.m and are you substituting "EGPScript.m" for "filename"?

Sign in to comment.

Answers (1)

It really looks, like the error happens in a different line.
S = load('filename', '-ascii')
This should work, if the file has the name "filename.mat". Please inspect the code again and post the relevenat parts here.

Asked:

on 13 Mar 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!