plot binary vectors ?
Show older comments
I have 2 vectors X and Y which represent spatial distribution of specific data points(100 points) as 2 column-vectors, they consists of 0s and 1s and I want to show their distribution in such a plot. I tried with the normal plot, scatter and a couple of Matlab commands, but the Matlab showed all points in one place (across 1 in the x-axis), which does not represent what am I looking for. I would be very grateful, if you could help me.
1 Comment
Star Strider
on 3 May 2016
What sort of ‘distribution’ plot do you want?
If all the data are either [0,1] or [1,0], a spatial plot is going to simply overplot them.
If you want to plot them as a function of row number, create a row number vector and use the stem function to plot them against it.
If you are looking for the distribution of distances between the 1 values or something similar, that would be easy enough to determine using the find and diff commands, and then you could fit that result to a Poisson distribution and plot it with the Statistics and Machine Learning Toolbox function histift.
Answers (1)
Brendan Hamm
on 4 May 2016
Would you be looking for something like this?
x = randi([0,1],100,2);
histogram2(x(:,1),x(:,2),'Normalization','pdf')
xlabel('x_1')
ylabel('x_2')
Categories
Find more on Exploration and Visualization 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!