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!