How I can plot average line on cdf plots?
data_cellular = readmatrix('tmobile5gmain.csv', 'Delimiter', ',', 'LineEnding', '\n');
data_cellularb = readmatrix('att5gmain.csv', 'Delimiter', ',', 'LineEnding', '\n');
fig = figure();
y_c = data_cellular(:, 2);
%y_u = data_cellularb(:, 3)
hold on;
y_h = data_cellularb(:, 2);
hold on;
c1 = cdfplot(y_c);
hold on;
c2 = cdfplot(y_h);
hold on;
%set(gca, 'XScale', 'log')
%c2 = cdfplot(y_u);
nbins = 50;
dist = 'Normal';

Réponses (1)

Nithin
Nithin le 1 Nov 2023
Hi Arijet,
I understand that you want to plot an average line on the CDF plots mentioned.
To implement this, kindly refer to the following steps:
  • Compute the Cumulative Distribution Function (CDF) for each dataset using the “cdfplot” function, as you have already done for “y_c” and “y_h”.
  • Calculate the average values for each dataset using the “mean” function and name them as “avg_c” and “avg_h”.
avg_c = mean(y_c);
avg_h = mean(y_h);
  • Plot the average lines on the CDF plots using the “line” function. Specify the x-values as the average values and the y-values as [0 1] to span the entire range of the CDF plot.
line([avg_c avg_c], [0 1], 'Color', 'red', 'LineStyle', '--');
line([avg_h avg_h], [0 1], 'Color', 'blue', 'LineStyle', '--');
For more information regarding the “cdfplot”, “mean” and “line” functions, kindly refer to the following documentation:
I hope this answer provides you with the required information regarding your query.
Regards,
Nithin Kumar.

Produits

Version

R2021a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by