plotting n paths of geometric brownian motion

조회 수: 8 (최근 30일)
jean claude
jean claude 2017년 10월 5일
답변: KSSV 2017년 10월 6일
hello, i wanna plot say 30 paths of gbm, my problem is how to plot those paths cause my matrix (X1) is 3 dimensions
dt=1/250;
r=0.2;
sig=0.4;
n=30;
obj = gbm(r, diag(sig), 'StartState', 100)
[X1,T] = obj.simulate(100, 'DeltaTime', dt,'ntrials',30);
plot(T,X1)

채택된 답변

KSSV
KSSV 2017년 10월 6일
Your X1 is a 3D matrix....of dimension 101X1X30. You squeeze it to 2D matrix, to remove unwanted dimension and then use plot.
dt=1/250;
r=0.2;
sig=0.4;
n=30;
obj = gbm(r, diag(sig), 'StartState', 100) ;
[X1,T] = obj.simulate(100, 'DeltaTime', dt,'ntrials',30);
X1 = squeeze(X1) ;
plot(T,X1) ;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by