Why doesn't MATLAB plot?
Mostra commenti meno recenti
stock = 100;
delta_t = 1 / 365;
volatility = 0.1;
for i = 1 : 5
stock = stock .* exp( volatility .* sqrt ( delta_t ) .* randn(1) );
disp( stock )
end
t = 1 : 5 plot(stock,t)
------------------------
Anyone could help please? Thank you
Tony
Risposta accettata
Più risposte (1)
Tiancong Sui
il 8 Ott 2013
0 voti
2 Commenti
Matthew Crema
il 8 Ott 2013
I'm guessing you want to save the value of stock in each iteration of the for loop. Try:
for i = 2 : 5
stock(i) = stock(i-1) .* exp( volatility .* sqrt ( delta_t ) .* randn(1) );
disp( stock )
end
Tiancong Sui
il 8 Ott 2013
Categorie
Scopri di più su Graphics Objects 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!