×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Importing and plotting ASCII file

Importing and plotting ASCII file

Importing and plotting ASCII file

(OP)
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.

RE: Importing and plotting ASCII file

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources