Plot text file
1 view (last 30 days)
Show older comments
I have a problem on plotting text data. I save it as .dat file. And then I use this code to plot data:
load tec.dat;
Time = tec(:,1)/3600;
Vtec = tec(:,2);
plot(Time,Vtec,'k');
My sampling y data is discontinuous. For example, the sampling time at 12000 second has y = 20.05. Then, the data skipped to the sampling time 57840 second that y = 6.14 (no data from 12000 - 57840 second). In fact, Matlab should not plot the y data between 12000 - 57840 second. However, Matlab also plots trend of the data from 12000 - 57840 second by itself as a linear line. How can I solve this problem?
1 Comment
Rick Rosson
on 10 Sep 2011
Please format your code. If you do not know how, please click on the link called "Markup help" (below).
Answers (1)
Rick Rosson
on 10 Sep 2011
There are several ways to do this.
One very easy method is to use the stem function instead of the plot function:
stem(Time,Vtec,'k');
Another method would be to insert the value NaN into the data vector at time steps where you have no valid data. You would also have to insert a corresponding time value (an actual number) in the time vector so that the time and data vectors would have the same size.
HTH.
Rick
0 Comments
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!