Selecting the correct output.
이전 댓글 표시
I have writen this section of code.
function SPaths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
SPaths = zeros(NRepl, 1+NSteps);
SPaths(:,1) = S0;
dt = T/NSteps;
nudt = (mu-0.5*sigma^2)*dt;
sidt = sigma*sqrt(dt);
for i=1:NRepl
for j=1:NSteps
SPaths(i,j+1)=SPaths(i,j)*exp(nudt + sidt*randn);
end
end
end
It represents the price of an option with s0 as the start price, mu as the drift, sigma as the volitality, T as time horizon, Nsteps as the time steps and NRepl as the number of runs.
With input - AssetPaths(10,.2,.05,1,60,1) I generate 61 coloums of prices and can plot a graph from those, what I need to be able to do is select the price at a set time eg coloum 10 or coloum 61 (the end) to find diffrences from the start price etc. any Ideas on what command to use or how to go about this would be much appreciated.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!