필터 지우기
필터 지우기

1000 paths of Brownian motion

조회 수: 2 (최근 30일)
Stefka
Stefka 2014년 1월 7일
답변: Laurent 2014년 1월 7일
I am trying to get 1000 simulations of Wiener process paths, each path consisting of 2000 Wt in a matrix 1000x2000. I am getting an error that the index of the matrix is out of bounds. Can someone help me how to get these 1000 paths in one matrix? Here is the code I have so far:
n=1000;
T=2;
dt=1/1000;
K=T/dt;
t=[0:dt:T];
W=[];
W(1,:)=0;
for k=1:n
for i=1:K
W(i+1,k)=W(i,k)+sqrt(dt)*randn;
end
end

답변 (1개)

Laurent
Laurent 2014년 1월 7일
You have to set the correct size of W before you do the loop. So instead of W=[]; you should use something like:
W=zeros(K+1,n);
Also you can then remove the W(1,:)=0; line

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by