Plot a huge data in Matlab

67 Ansichten (letzte 30 Tage)
sally_wu
sally_wu am 14 Okt. 2015
Kommentiert: Umar am 28 Jul. 2024
I am trying to plot a cdf with the following data. I have a huge data with one column and total numbers are 116100 i.e. 116100x1 double. A minimum=0, maximum=1734719, average=1022, and standard deviation=16312. Every my attempt to plot the ecdf is crushed and shows just a straight line instead of showing a curve (cdf). I think Matlab cannot handle such big data.
  1 Kommentar
Umar
Umar am 28 Jul. 2024

Hi Sally,

Since I don't have the actual dataset, I will generate some random data that resembles the characteristics provided (116,100 data points, minimum=0, maximum=1,734,719, average=1022, standard deviation=16,312).

% Generate random data

data = 16312 * randn(116100, 1) + 1022;

Next, I will calculate the CDF values for the dataset and use the ecdf function in MATLAB to compute the empirical CDF.

[f, x] = ecdf(data);

Now, I can plot the CDF using the generated data and CDF values. language-matlab

figure;

plot(x, f, 'LineWidth', 2);

xlabel('Data Points');

ylabel('Cumulative Probability');

title('Cumulative Distribution Function (CDF) Plot');

grid on;

Please see the attached plot.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Kirby Fears
Kirby Fears am 14 Okt. 2015
Matlab can easily plot this data. Is each column of your 116100x4 double a separate variable that you want to plot?
Try plotting one column of Y values against whatever your X values are, e.g.
plot(X,Y(:,1));
Below is a simple example that plots a normal distribution with mu and sigma as you indicated.
X=(1:116100)';
Y=1022+16512*randn(size(X));
plot(X,Y);
This plot looks exactly as expected. Since there are so many X observations, the plot looks very compressed along the X axis. You could "zoom in" on a portion of the data to get a better view, as done below.
idx=1:100;
plot(X(idx),Y(idx));
Much more detail is visible when fewer points are observed. You could apply this approach to a 4-column Y matrix as well if you want to see all 4 variables at once on a subset of X values.
% to plot a subset of Y column 1
plot(X(idx),Y(idx,1));
% to plot a subset of all 4 variables
plot(X(idx),Y(idx,:));
You may also be interested in plotting every 100th observation to thin out the sample and make it more readable. To do this, assign idx = 1:100:length(X);
Hope this helps.
  3 Kommentare
sally_wu
sally_wu am 14 Okt. 2015
I have this 116100x1, and want to plot ecdf
Kirby Fears
Kirby Fears am 14 Okt. 2015
Bearbeitet: Kirby Fears am 14 Okt. 2015
The point of my answer is to demonstrate how to plot any vector of this size. Using the ecdf() output is no different. Here is an example:
X=(1:116100)';
Y=1022+16512*randn(size(X));
[a,b] = ecdf(Y);
plot(b,a);
Please give this a try and adapt it to work for your own code.
Hope this helps.

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by