Plotting e^{t + W(t)/2} by calling W(t) function file

I'm trying to plot/figure out why this file isn't working out the way I wanted it to. I have to plot e^{t + W(t)/2} and I'm calling W(t) from a previous file as seen from the brownianPath(T,n). It gives me an exponential curve, which I think isn't what is supposed to happen because when I try to find the mean and plot that, it gives me an error. Thank you.
function [U] = expBrownianPath(T,n)
s = T/n;
t = 0:s:T;
U = zeros(1,n);
W = zeros(1,n);
for j = 2:n
W(j) = brownianPath(T,n);
U(j) = exp(j + (W(j)/2));
end
plot([0:s:T],[0 U], 'g-');
end

 채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 11일

0 개 추천

U(j) = exp(j + (W(j)/2));
should use
U(j) = exp(t(j) + (W(j)/2));
and your plot should be plot(t, U)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

질문:

2018년 2월 11일

답변:

2018년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by