MATLAB: Can’t get this to plot (Asian Option)

monte carloStatistics and Machine Learning Toolbox

Hi
Needing help.
I am trying to plot this code (NRep 1 on the X axis, Y on the Y-axis) but am hitting too many input argument errors etc. I need to plot it for a range of the NRep1: say 0 to 100,000 in increments of 10000 (say), but for the life of me can't get it to work.
How do I input this range and then plot without hitting any errors?
Many, many thanks in advance
Joe
The code is as follows:
function Y=AsianCallH(NRep1)
% AsianCall calculates the approximate value of the Asian Call Option
% based on the motion of the underlying asset price with random sequences
% Format of Call: AsianCall(S0,K,r,T,sigma,NSteps,NRep1)
% S0: Current asset price
% K: Strike Price
% r: Riskfree rate
% Sigma: The standard deviation
% NSteps: The number of steps(dimensions) between t=0 and t=T
% NRep1: Number of simulations per time step
S0=75;
K=75;
r=0.015;
T=2;
sigma=0.30;
NSteps=24;
% NRep1=50000
dt=T/NSteps;
drift=(r-0.5*sigma^2)*dt;
vari=sigma*sqrt(dt);
Increments=drift+vari*Halton(NSteps,NRep1);
LogPaths=cumsum([log(S0)*ones(NRep1,1),Increments] ,2);
% Now the underlying asset path is generated
SPath=exp(LogPaths);
Payoff=zeros(NRep1,1);
Payoff=max(0,mean(SPath(:,2:(NSteps+1)),2)-K);
Y=mean(exp(-r*T)*Payoff);
end
For completion the Halton code is:
function HaltonMat = Halton(NSteps,NRep1)
% This function will use the grandstream Matlab function
% to simplify the Halton
q=qrandstream('halton',NSteps,'Skip',1e3,'Leap',1e2);
% Defines a function which generates the quasi points from the
% qrandstream function
RandMat=qrand(q,NRep1);
% HaltonMat will geneate the NRep1*NSteps matrix
HaltonMat=norminv(RandMat,0,1);
end

Best Answer

Yeah, it's exactly what it says it is--you've defined
NRep1=1:1000:100000;
as a vector and passed it to
AsianCallH(NRep1))
which calls qrandstream/qrand with that vector when the input N must be a positive scalar integer. The output is then an NxD array.
You'll have to call in a loop over your number of points or use arrayfun perhaps since qrand isn't vectorized internally.