Plot multiple probability distribution function lines on one plot in MatLab - matlab

I'm new to matlab and am trying to work with three dimensional data. It has latitude, longitude and time as the three dimensions, and I want to create a PDF for each of these matrices and then put all of them on the same plot rather than have three separate PDF plots. I don't know how to create reproducible data for matlab for this question so if there are more questions I can provide more guidance (also would be happy to hear guidance about how to create reproducible 3 dimensional data).
Essentially I need help creating a probability distribution function for three dimensional data, and then I want to plot multiple PDF lines on the same figure.
I've tried using the histogram function and normplot() but neither has worked.

Related

k-means algorithm for energy data against time and date

I am using Matlab 2015a.
I have got electricity consumption data to cluster it. Initially i am trying to cluster it against hours and dates. I have created three different variables, one for time, one for dates and third for data. I am unable to understand how should i combine these in a matrix form so that the loads are distributed according to time? Then i have tried to look how can i plot a line graph for k-means but i can only find scatter command graphs but no line plots.
Further how can i plot it as a 3-d plot?
Further at a later stage i want to include temperature variable aswel. But when the 4th variable is involved, what will the plot be? will it still be 3-d?
Any suggestions, links?
In Matlab you can create N-dimensional matrices, so you can arrange your 3D data in a N*M*3 matrix (you might want to look for the cat() function to help you out).
There are several functions that allow you to plot in 3D, one of these is scatter3() which is perfect for K-Means clustering. I don't really understand which lines you do want to plot: K-Means is about clusters and centroids (i.e. points).
If a 4th variable is involved, you can as well create a 4D matrix. Although I reckon plotting a 4D graph isn't going to be easy. A first approach might be using several colours for your scatter points with different colours for different temperatures (or temperatures range). In this case the 5th input argument for scatter3() will be helpful.
Help for scatter3() here.
Help for cat() here.

How to correlate two vectors not only using their shape but also consider their values in matlab?

I want to correlate two vectors not only in their shape but also considering their values in matlab. The functions i've searched (like, corrcoef/corr/corr2...) give the R-value, but that just consider the shape of the curve that the vectors represent, and i want to know also how close their values are. Is there any function that consider these both criteria(shape and values)?
Thank you so much in advance!

How to reduce size of printed eps when plotting large amounts of data

I am Plotting and printing a large dataset to eps:
plot(Voltage,Torque,'b.')
print -depsc figure.eps
Through these million data points I will fit a graph. However since the sizes of the Voltage and Torque vectors are enormous my eps file is 64.5 MB.
Most of the plotted points however lie on top of other points or very close. How can I reduce the size of the .eps while still having limited effects on the way the data is shown in the graph? Can I make matlab detect and remove data points close enough to other already plotted points?
although it is a scatter plot, I am not using scatterplot since all points should have the same size and color. Is it possible to use scatterplot to remove visual obsolete datapoints?
Beyond stackoverflow, the File Exchange is always a good place to start the search for a solution.
In this case I found the following submissions:
Plot (Big):
This simple tool intercepts data going into a plot and reduces it to the smallest possible set that looks identical given the number of pixels available on the screen.
DSPLOT:
This version of "plot" will allow you to visualize data that has very large number of elements. Plotting large data set makes your graphics sluggish, but most times you don't need all of the information displayed in the plot.
If you end up using the plot in a LaTeX-file, you should consider using
matlab2tikz:
This is matlab2tikz, a MATLAB(R) script for converting MATLAB figures into native TikZ/Pgfplots figures.
For use in LaTeX you don't have to go the detour of PostScript and it will make for beautiful plots.
It also provides a function called: CLEANFIGURE('minimumPointsDistance', DOUBLE,...), that will help you reduce the data points. (Possibly you could also combine this with the above solutions.)
If your vector Voltage is already sorted and more or less regularly spaced, you can simply plot a fraction of the data:
plot(Voltage(1:step:end),Torque(1:step:end),'b.')
with step set to find the right tradeoff between accuracy and size of your eps file.
If needed, first sort your vectors with:
[Voltage,I] = sort(Voltage);
Torque = Torque(I);

Creating pairwise cluster plot with histograms down diagonal (similar to FisherIris Demo)

I have 8 columns of data and want to create a pairwise scatter plot like the one in the Kevin Murphy Book
I was told there is code online to create this found it here, but i dont see how it seems to cluster the data and i dont know how to adapt it to my data

Extract only one spike from matlab plot

I have a matlab plot between two matrices (129 by 1), I just want to extract the only first spike from the multiple spikes as seen in plot. I am newbie to Matlab.
-John
Either code your own or use this peak finder algorithm. That one works very well.