MATLAB Answers

Plot curve becomes jagged after 1000 data points (seems to plot one point and stretch it the length of 10)

8 views (last 30 days)
Camden Boston
Camden Boston on 25 Jun 2020
Commented: Piscies on 6 Oct 2020
I am trying to execute the following code:
dataset = importfile('MyFile.csv');
%initialize variables
time = dataset(:,2);
rolls = dataset(:,3);
The importfile function was made using Matlab's automatic tools to bring over my data set (the vectors are approx. 1900 in length).
Matlab prints the plot attached, and you can see that right at about data point 1000 the plot gets linear with what looks like Matlab drawing a straight line between every 10 points.
The other image I attached is an excel plot of the origanal data and I also coppied over the 'rolls' vector that Matlab imported. Both of the excel plots display as expected which tells me that the data is being correctly imported to Matlab.
Any comments appreciated.
  1 Comment
Piscies on 6 Oct 2020
Have you been able to figure this out? I am having the same issue with my imported data. It's weird because another dataset with the same number of points I imported previously did not have the issue, but the second dataset I tried did.

Sign in to comment.

Answers (1)

Kelly Kearney
Kelly Kearney on 25 Jun 2020
It's difficult to say without actually seeing the underlying data... but at first glance this looks like a change in precision in the time variable. See, for example, the differences in the example below:
x = linspace(0,20,100);
y = rand(100,1);
plot(x,y, round(x),y);
The latter gives the same "vertical bars joined by longer straight lines" look as the latter part of your data. I'd check to see if something changed in the way the time data was recorded in your original dataset.




Community Treasure Hunt

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

Start Hunting!