Help with heat equation
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello I have the following question
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191270/image.png)
I am trying to understand how to do from the heat equation part Can anyone help?
댓글 수: 0
답변 (1개)
Image Analyst
2018년 6월 15일
Try
sigma = 0.2;
r = 0.05;
S0 = 10 : 10 : 100;
K = 50
T = 2
xmax = 10
xmin = -10
N = [10, 100, 200, 400, 800];
M = N
for k = 1 : length(N)
thisM = M(k);
thisN = N(k);
blsprice(................
absoluteError = .........
plot(S0, absoluteError, 'b*-');
hold on;
grid on;
end
I don't know what "the Call Option" or the heat equation or blsprice() is so I can't help with that, but at least this is a start. Presumably blsprice() uses those parameters as inputs. I'm also not sure how to calculate the absolute error.
댓글 수: 3
Image Analyst
2018년 6월 15일
You can't do
for n = 2:N
because N is an array. You have to think what you really want. You need to extract the values of M and N from the array and use them somehow.
Even if you did
for n = N
which is allowed, n would take on the value of N(1) first, which is 10. So then you say
v(1, 10) = v(1,1);
well, what about the rest of the array? What about columns 2 through 9?
You also shouldn't do
v = zeros(M,N);
because they're arrays. You can if you use thisM and thisN and put that inside the loop as I showed you. Take another crack at it.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!