I want to plot X & Y data for different Time step.

5 views (last 30 days)
Any one could help me> I am very new at matlab.
I'm trying to figure out a way to show in a scatter plot. I have excel and text file data file where at 900 sec I have 44 xy points, at 950 sec 234 points,....., at 1150 sec 260 points. How can I do that.
Example data:
# THIS IS A EXTINCTION PLOT FILE
# The Time Passed = 900
# The Volume Entered = 0.000156572
XPOS YPOS AF
0.22 0.105 0.00000D+00
0.215 0.105 0.00000D+00
0.215 0.105 0.00000D+00
0.21 0.105 0.00000D+00
0.205 0.105 0.00000D+00
0.205 0.105 0.00000D+00
0.14 0.095 0.00000D+00
0.135 0.095 0.00000D+00
....
....
0.23 0.095 0.00000D+00
0.23 0.1 0.00000D+00
0.225 0.105 0.00000D+00
0.22 0.105 0.00000D+00
# THIS IS A EXTINCTION PLOT FILE
# The Time Passed = 950
# The Volume Entered = 0.000156707
XPOS YPOS AF BF CF
0.22 0.105 0.00000D+00
0.215 0.105 0.00000D+00
0.215 0.105 0.00000D+00
0.21 0.105 0.00000D+00
0.205 0.105 0.00000D+00
....
0.23 0.075 0.00000D+00
0.23 0.08 0.00000D+00
0.23 0.08 0.00000D+00
0.23 0.085 0.00000D+00
0.23 0.09 0.00000D+00
0.23 0.09 0.00000D+00
0.23 0.095 0.00000D+00
0.23 0.1 0.00000D+00
0.225 0.105 0.00000D+00
0.22 0.105 0.00000D+00

Accepted Answer

Geoff
Geoff on 1 Apr 2012
How about this:
hold off;
scatter( x1, y1, 'bo' ); % Blue circles
hold on;
scatter( x2, y2, 'gv' ); % Green triangles
scatter( x3, y3, 'rs' ); % Red squares
hold off;
legend( '900 seconds', '950 seconds', '1150 seconds' );
The hold on command will cause new plots to be added to the existing figure.

More Answers (3)

Tan Has
Tan Has on 2 Apr 2012
Thanks.
All this coordinates falls within the 54x78 grid (number of grid 4212). I want to plot all these data within this area.
How matlab reads xy data in different time steps?
Should I need to use i (ex: i=18, where 18x50=900sec. 1 time step 50 sec)to define which data it going to plot.
how matlab read 44 xy points(900 sec) from the file and then it reads 234 points in the next time step (950)?

Tan Has
Tan Has on 2 Apr 2012
I am trying this. but My plot needs to show within 54x78 grid. How can I plot the next time step by only change the i value into 2 (for 950 sec)? where xy has 234 points.
************************
i=1;
% fh=figure;
m=4+(i-1)*48;
n=47+(i-1)*48;
M=dlmread('Extinction_Node.plt',',',m,0, [m 0 n 3]);
xarray=M(:,1);
yarray=M(:,2);
EXT=M(:,3);
hold off;
scatter( xarray, yarray, 'bo' );
  2 Comments
Geoff
Geoff on 2 Apr 2012
Does your data have a column of time values in it? The usual thing to do (let's say that column 4 has the time) is:
t = M(:,4);
x900 = xarray(t==900);
x950 = xarray(t==950);
... etc
Otherwise, if you really want to read different data lengths and you know the lengths already, don't use those formulae for 'm' and 'n'. Just do one read for each set. That is, hard-code the row and column into multiple calls to 'dlmread'.
Geoff
Geoff on 2 Apr 2012
Sorry, I forgot you had given a sample data file. The easiest way for you to proceed will be to hard-code the numbers as in my second suggestion above.

Sign in to comment.


Tan Has
Tan Has on 2 Apr 2012
How can I make the figure background transparent? So that I can Plot that into my another graph.
  1 Comment
Geoff
Geoff on 2 Apr 2012
That's what 'hold on' does. It plots onto the same axes as the last plot. You have a lot of questions, and it is not helpful to post them here. Post a new question when you need to know something, so that other people can search for relevant answers if they want to do the same thing.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!