Plot a huge data in Matlab

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 件のコメント

Umar
Umar 2024 年 7 月 28 日

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.

サインインしてコメントする。

回答 (1 件)

Kirby Fears
Kirby Fears 2015 年 10 月 14 日

1 投票

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 件のコメント

sally_wu
sally_wu 2015 年 10 月 14 日
Thank you for your answer,but I would like to plot ecdf...examples that you provided guess a lit bit different? when i tried to plot them it gave me spikes (lines)....
sally_wu
sally_wu 2015 年 10 月 14 日
I have this 116100x1, and want to plot ecdf
Kirby Fears
Kirby Fears 2015 年 10 月 14 日
編集済み: Kirby Fears 2015 年 10 月 14 日
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.

サインインしてコメントする。

製品

質問済み:

2015 年 10 月 14 日

コメント済み:

2024 年 7 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by