Effacer les filtres
Effacer les filtres

Scatter plot matrix data while keeping it considered as one data series?

1 vue (au cours des 30 derniers jours)
PetterS
PetterS le 28 Avr 2015
Commenté : Star Strider le 28 Avr 2015
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

Réponse acceptée

Star Strider
Star Strider le 28 Avr 2015
I’m not certain this is an acceptable option for you, but instead of for ‘tilt’, I would substitute it with a very small number (perhaps 1E-8).
  2 commentaires
PetterS
PetterS le 28 Avr 2015
You mean earlier in the process so I end up with vectors instead of matrices? I’m not sure I can do that because I’m getting the orientation/tilt matrices from searching through a 1440x181x180 matrix (minute,tilt,orientation) and having matlab find the largest value for each minute. What I get out from that search are the A and B matrices I described and then I don’t think the situation will change if I adjust the tilt numbers, I already have it in matrix form. And also – having 0° tilt and all orientations is considered a perfectly valid solution for me, so I would still like to have that as an option, I’m just struggling to plot it in a way that makes sense.
Star Strider
Star Strider le 28 Avr 2015
I misunderstood.
Since scatter only wants vectors, and all your other data are in a vector, I see two options: don’t plot data, or plot them as [0,0]. (My preference would be to not plot the data at , since the orientation there is essentially undefined.)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by