draw exppdf, excdf and plot command exponential distribution in matlab

main.m
% Define the parameter for the exponential distribution
lambda = 0.5; % Rate parameter

% Create a vector of x values for plotting the PDF and CDF
x = 0:0.01:10;

% Calculate the PDF for the exponential distribution
pdf_values = exppdf(x, 1/lambda); % Note: MATLAB uses 1/lambda as the scale parameter

% Calculate the CDF for the exponential distribution
cdf_values = expcdf(x, 1/lambda); % Note: MATLAB uses 1/lambda as the scale parameter

% Plot the PDF
figure;
plot(x, pdf_values);
title('Exponential Distribution PDF');
xlabel('x');
ylabel('Probability Density');

% Plot the CDF
figure;
plot(x, cdf_values);
title('Exponential Distribution CDF');
xlabel('x');
ylabel('Cumulative Probability');
701 chars
26 lines

gistlibby LogSnag