Scatter plot matrix data while keeping it considered as one data series?
1 view (last 30 days)
Show older comments
I have two variables, variable A contains information about the orientation of a surface for each minute of a day, variable B contains information about its horizontal tilt. In a perfect world that would mean that they are vectors of size 1440x1. However, at times when the tilt is 0° my program is unable to define a single optimal orientation since all horizontal orientations are equal, so it returns all orientations, making my variables 1440x180 matrices. Where sometimes variable B contains 180 repetitions of tilt = 0° and variable A counts all orientations 1,2,3..180.
I want to scatter plot these so that I have orientation on the X-axis and tilt on the Y-axis. But if I just type:
scatter(A,B);
I get “error using scatter, X and Y must be vectors of the same length.”. Is that because the scatter command doesn’t work with matrices or could it be that I have nans inside the matrices or something else?
If I instead plot it like this:
for i=1:size(A,1)
scatter(A(i,:),B(i,:)); hold on
end
then it doesn’t complain and It plots it like I want but this takes a lot of time and if I turn the legend on I now have 1440 data names since each plot is considered a new set of data. And since it’s considered 1440 individual plots I can’t for example apply a gradient color across the data to represent things that I want.
Does anyone know how to scatter plot a situation like this without using the loop and keeping it one timeseries?
thanks
0 Comments
Accepted Answer
Star Strider
on 28 Apr 2015
I’m not certain this is an acceptable option for you, but instead of 0° for ‘tilt’, I would substitute it with a very small number (perhaps 1E-8).
2 Comments
Star Strider
on 28 Apr 2015
I misunderstood.
Since scatter only wants vectors, and all your other data are in a vector, I see two options: don’t plot 0° data, or plot them as [0,0]. (My preference would be to not plot the data at 0°, since the orientation there is essentially undefined.)
More Answers (0)
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!