matlab中zeros a b c,求高手C=[A B zeros(n,n2-2*n)] 的意思

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

Copy and paste the following programme into the MATLAB editor and save the program as five_point.m clear all; % clears all variablesn = 10; % number of points used in each direction n2 = n^2; % denote n^2 by n2 for simplicity and e±ciencyh = 1/(n+1); % set up the difference stepsize h x_with_boundary = linspace(0,1,n+2)'; % create the vector (x0; x1; … ; xn+1) x = x_with_boundary(2:n+1); % create the vector (x1; x2; …: ; xn) from the above vector[xx,yy] = meshgrid(x,x); % create grid matrices A = ( diag(ones(1,n-1),-1) ... % create sub-matrix A+ diag(-4.*ones(1,n),0) + diag(ones(1,n-1),1)); B = diag(ones(1,n),0); % create sub-matrix BC=[A B zeros(n,n2-2*n)]; % construction of the matrix C for i=1:n-2 C=[C; zeros(n,(i-1)*n) B A B zeros(n,n2 - (2+i)*n)]; end C=[C; zeros(n,n2-2*n) B A]; rhs = h^2.* f4(xx,yy); % read the values for the rhs matrix from f4.mrhs = reshape(rhs,n2,1); % reshape matrix rhs to an n2×1 vector sol = C\ rhs ; % solve the linear system to find solsol_mat = reshape(sol,n,n); % reshape vector sol to an n× n matrixsurf (xx,yy,sol_mat); % plot the resulting approximation to utitle('numerical approximation of the solution') % title of the graphOpen a new document in the MATLAB editor. Copy and paste the following programme and save it (in the same directory as five_point.m) as f4.m function z = f4(x,y) % declare that this M-file is a function f4 with arguments x, yz = -(2.*pi^2).*sin(pi.*x).*sin(pi.*y); % define the formula of the function f4.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值