Matrix Dimension mis-match problem
显示 更早的评论
I have a very quick question. I am working through a finite difference problem (1D steady-state heat transfer) and am having trouble getting the coefficient matrix A, shown below:
n = length(dL);
A = diag(ones(n-1),-1)-2*eye(n)+diag(ones(n-1),1);
I am getting the error:
Error using -
Matrix dimensions must agree.
Error in final (line 85)
A = diag(ones(n-1),-1)-2*eye(n)+diag(ones(n-1),1);
Can someone please tell me where my error is? I feel like this is extremely straight-forward and should be working.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!