Scatter plot matrix data while keeping it considered as one data series?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2015-4-28
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 个评论
Star Strider
2015-4-28
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.)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!