フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Indexing problem for matrix

1 回表示 (過去 30 日間)
Dam
Dam 2014 年 1 月 10 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Good morning , i have a question related to indexing for the following
S=100;
T=1;
sig=[0.05:0.01:0.45];
m=0.07;
t=1/252;
E_T=0;
in=S*ones(1,41)%41 size sig;
while E_T < T -10^(-5)
E_T=E_T+t;
sig=[0.05:0.01:0.45];
Multip = exp((m-sig.^2/2)*t+sig.*sqrt(t).*randn(1,1));
S = S.*Multip;
in=[in S];
end
in=vec2mat(in,41,253);
i try to use more than 1 random number ex:randn(3,1) or (1,3) and then put the results for each value of sig in one raw (or colomn) Thank you in advance Best regards

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 10 日
S=100;
T=1;
sig=[0.05:0.01:0.45];
m=0.07;
t=1/252;
E_T=0;
in=S*ones(3,41)%41 size sig;
while E_T < T -10^(-5)
E_T=E_T+t;
sig=[0.05:0.01:0.45];
Multip = bsxfun(@times,exp((m-sig.^2/2)*t+sig.*sqrt(t))',randn(1,3))';
S = S.*Multip;
in=[in S];
end
  2 件のコメント
Dam
Dam 2014 年 1 月 10 日
Thank you for your answer , but it is apparently not generating the results I want as for Multip equation it is simply Multip= exp((m- sig^2/2)*t+sig*sqrt(t)*randn) So the random number is inside the exponentail and it is first mutiplied by sig*sqrt(t) only
Dam
Dam 2014 年 1 月 10 日
編集済み: Dam 2014 年 1 月 10 日
Actually it is bsxfun(@times what i needed ... I used it differntly and it works now: A = (ones(3,1)*((m-sig.^2/2)*t)) B=bsxfun(@times, sig.*sqrt(t),randn(3,1)); Multip=exp(A+B); Thank you

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by