Excluding data points from a file

조회 수: 8 (최근 30일)
Dugalls
Dugalls 2013년 6월 1일
I have a data file full of lengths and areas of cube cluser at tifferent time. The format of the data file looks like:
t a r
0 1 .23
0 4 1
... ... ...
Though the points are relevant, I don't need them all. What I'd like is to have mat lab plot the points for whenever a > 4. But every time I try something, I run out of memory (note: there are 52500+ points in this data file, hence why I'm trying to get rid of unnecessary points). Is there a way that it can go through all the data, and plot when a is grater than 4 with the corresponding r? If I could allocate the memory, that'd be great but I have to do this for multiple files, and each file has a different total number of points, so I can't just fix a number to the memory matrix. The code looks like the following so far:
fia=(fopen('data.txt');
A = fscanf(fia, '%f %f %f', [3,inf]);
a1 = A(2,:);
r1 = A(3,:);
a=a1(a1>4);
hold all
plot(log(r),log(a));
Would a while function work, for I tried hat, but I still ran out of memory. Thank you.

채택된 답변

Image Analyst
Image Analyst 2013년 6월 1일
Did you also do
r = r1(a1>4);
??
Why not just try subsampling:
a = a1(1:64:end);
r = r1(1:64:end);
Assuming the nature of the points doesn't really change much from the beginning to the end, this could give you the general impression of what the whole data set looks like, while plotting a lot fewer points. You probably only have a couple thousand pixels across your screen so it doesn't make much sense to plot more than that.
  댓글 수: 1
Dugalls
Dugalls 2013년 6월 1일
Thanks! That worked out perfectly.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by