Help with heat equation
Show older comments
Hello I have the following question

I am trying to understand how to do from the heat equation part Can anyone help?
Answers (1)
Image Analyst
on 15 Jun 2018
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 Comments
Janvier Solaris
on 15 Jun 2018
Image Analyst
on 15 Jun 2018
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.
Janvier Solaris
on 16 Jun 2018
Categories
Find more on Structural Mechanics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!