Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing and plotting ASCII file

Status
Not open for further replies.

fatpo

Electrical
Dec 27, 2004
17
SE
I have a ASCII file with measurments of a signal. I want to import the data in Matlab and plot the resulting curve. The thing is that the file contains at least 100k values. I wonder if Matlab has any limitation problems with this? I tried this:
------------------------------
clear all;
global arrays, double(i);
fid=fopen('usart.txt');
for i=1:100000
tline = fgetl(fid);
if ~ischar(tline)
break
end
if str2num(tline)
arrays(i)=str2num(tline);
else
i=i-1;
end
end
fclose(fid);
arrays=arrays(find(arrays));
plot(arrays)
------------------------------

I can plot up to app.2000 values but thats it. I get this error message:

??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> C:\rs232 med 18f2455\test.m
On line 10 ==> arrays(i)=str2num(tline);


Any suggestions? Is this the right way to inport large values?? Thanks in advance.
 
Replies continue below

Recommended for you

If you just have a list of numbers you could try
load usart.txt
arrays = usart;
plot( arrays )

Also, i is a restricted keyword in MATLAB, but that is not related to youyr problem, unless you have complex numbers in your data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top