Error: In an assignment A(I) = B, the number of elements in B and I must be the same.
Mostra commenti meno recenti
The main code below for function Vt creates a 241 x 1 matrix. I want to repeat the calculations and store it in a new matrix that is 241 x 10, so each column has a new set of data repeated.
When I try this as shown below i get the error message? How do i change it to get a 241 x 10 matrix.
for j=1:10
Vt(j) = V*exp((r-(sigma^2)/2)*(0:1:N)'/N*T+ sigma*([0; cumsum(randn(N,1))]/sqrt(N))*sqrt(T));
end
Error: In an assignment A(I) = B, the number of elements in B and I must be
the same.
function Firmvalue = GBM_FV(V,K,T,r,sigma)
%T = 20; % Time until maturity
%r = 0.05; % The risk free interest rate
%sigma = 0.20; % The asset volatility
%V = 100; % Starting asset value
%K = 75; % The principal of the debt
N = 240;
Vt = V*exp((r-(sigma^2)/2)*(0:1:N)'/N*T+ sigma*([0; cumsum(randn(N,1))]/sqrt(N))*sqrt(T));
3 Commenti
Jan
il 12 Mag 2012
Because we neither know the size of "sigma", "r" and "T", nor the value of "N", we cannot run your program. In addition it is not clear, which variable you want to be a [241x10] array. It would be helpful, if you mention, which line causes the error.
Sap
il 12 Mag 2012
Sap
il 12 Mag 2012
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!