1
$\begingroup$

I am trying to plot the following function in MATLAB

$$f(x) = \lambda e^{-\lambda(x-\Delta)}w(x-\Delta) $$

where $$w(x) = \begin{cases} 1 &x \geq 0 \\ 0 & {\rm otherwise}\\ \end{cases} $$

I chose a value of $\lambda$ of 1 and $\Delta$ of 2. I am just not sure how to define $w(x)$ and shift the function by delta. Thank you.

$\endgroup$
4
$\begingroup$

You can plot samples of a continuous density function just as you would do with any continuous function. Assuming $w(x)$ represents the continuous-time unit step function,

$$w(x-\Delta) = \begin{cases}{ 1 ~~~,~~~x \geq \Delta \\ 0 ~~~,~~~ \text{otherwise} } \end{cases}$$

then the shifted exponential pdf can be plotted with the following matlab/octave code :

clc; clear all; close all

K1 = -1;        % evaluation interval begins
K2 = 9;         % evaluation interval ends
N = 1000;       % number of points to display
x = linspace(K1,K2, N); % x = domain to use for displaying 


lam = 1;        % exponential PDF parameter
delta = 2;      % shift amount
f = lam*exp(-lam*(x-delta));
f = f.*(x>delta);   % to implement w(x-delta)

figure, plot(x,f);
title('shifted exponential pdf for \lambda = 1, \Delta = 2');

The output will be:

enter image description here

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Thank you very much! $\endgroup$ – user367640 Nov 24 '19 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.