% Crank-Nicolson 法解一维薛定谔方程 % 等间距网格,稀疏矩阵 function TDSE_cn1d % === 参数设置 === xmin = -80; xmax = 80; Nx = 1000; % x 网格 tmin = 0; tmax = 20; Nt = 400; % 时间网格 Nplot = 10; % 画图步数 ax = [xmin, xmax, -0.5, 0.5]; % 高斯波包 x0 = -17...
考虑到三对角矩阵特殊性,关于matlab中diag函数操作可以参见官Matlab diag函数官方文档,追赶法求解三对焦矩阵代码如下: functionx=shoot_method(A,f)%LU分解思路的追赶法求解三对角阵%输入:Ax=f中A,f%输出:xlen_f=length(f);%矩阵尺寸a=[0;diag(A,-1)];b=diag(A,0);c=diag(A,1);%获取对角元素l=zero...
Matlab:Crank Nicolson方法求解线性抛物方程 1tic;2clear3clc4M=[10,20,40,80,160,320,640];%x的步数5K=M; %时间t的步数6forp=1:length(M)7hx=1/M(p);8ht=1/K(p);9r=ht/hx^2; %网格比10x=0:hx:1;11t=0:ht:1;12numerical=zeros(M(p)+1,K(p)+1);13numerical(:,1)=exp(x); %...
MATLAB Online에서 열기 ive copied the codes for Crank-Nicolson finite difference method, but it wont run and keeps showing this error msg 'Error: Function definitions are not permitted in this context.', any idea to fix this? thx guys :) ...
Open in MATLAB Online f is always the definition of the method you try to implement. Euler-implicit: f = y_new - y_old - h*odeSystem(x(i4+1),y_new) corresponds to (y_new - y_old)/h = f(x_new,y_new) Crank-Nicolson: ...
CEV-Option-Pricing-Crank-Nicolson 是一个使用Crank-Nicolson方法计算CEV模型下期权价格的Matlab程序。CEV模型是一种用于描述金融市场中波动率跳跃性的方法,它假设资产价格遵循一个具有跳跃过程的随机过程。在这个程序中,我们首先定义了一些参数,如无风险利率、股票价格、波动率等。然后,我们使用Crank-Nicolson方法来求解...
求解一维热传导方程Crank-Nicolson差分法
Crank-Nicolson method is applied to analyze the solution of this equation. Also, the solution and the graphs of the expected value and variance are obtained by using MATLAB software. The results of the heat equation are compared with random characteristics of this equation. Firstly, a random ...
Da**sy上传3KB文件格式zip 使用Krank-Nicholson 方法求解抛物线方程的数值解 (0)踩踩(0) 所需:1积分 MCS51 CircleMN 2025-04-03 00:01:31 积分:1 JavaScript-compiler 2025-04-03 00:09:38 积分:1 德浓欠我钱 2025-04-03 00:18:14 积分:1 ...
Crank-Nicolson有限差分法对欧式障碍期权定价,以欧式看跌期权为例,运用Matlab编程, 将所得两个结果与基于公式解的结果进行比较,结果表明Crank-Nicolson有限差分法比 Monte-Carlo方法更优。 关键词:Monte-Carlo;障碍期权;有限差分方法;欧式看跌期权 中图分类号:F832.51 ...