matlab 稀疏矩阵插值为题现有(10×10)矩阵230002200002900000000000025000000000000250000250000000000000000000000000000000028025002602800000000033026000

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/06 07:11:41
matlab稀疏矩阵插值为题现有(10×10)矩阵230002200002900000000000025000000000000250

matlab 稀疏矩阵插值为题现有(10×10)矩阵230002200002900000000000025000000000000250000250000000000000000000000000000000028025002602800000000033026000
matlab 稀疏矩阵插值为题
现有(10×10)矩阵
2300022000029
0000000000
00250000000
00000250000
25000000000
0000000000
0000000000
0002802500260
28000000000
3302600000025
如果用正常的二维插(interp2)方法,0的位置还是0,这不是我希望得到的结果.
能否仅利用矩阵中已有的数据点(非零点)进行插值,得到一个新的平滑非稀疏矩阵.

matlab 稀疏矩阵插值为题现有(10×10)矩阵230002200002900000000000025000000000000250000250000000000000000000000000000000028025002602800000000033026000
A = [23, 0, 0, 0, 22, 0, 0, 0, 0, 29; ...
0, 0, 0, 0, 0, 0, 0, 0, 0, 0; ...
0, 0, 25, 0, 0, 0, 0, 0, 0, 0; ...
0, 0, 0, 0, 0, 25, 0, 0, 0, 0; ...
25, 0, 0, 0, 0, 0, 0, 0, 0, 0; ...
0, 0, 0, 0, 0, 0, 0, 0, 0, 0; ...
0, 0, 0, 0, 0, 0, 0, 0, 0, 0; ...
0, 0, 0, 28, 0, 25, 0, 0, 26, 0; ...
28, 0, 0, 0, 0, 0, 0, 0, 0, 0; ...
33, 0, 26, 0, 0, 0, 0, 0, 0, 25];
[X,Y,Z]=find(A);
[x,y]=find(A==0);
z=griddata(X,Y,Z,x,y,'cubic');
n=length(x);
for i=1:n, A(x(i),y(i))=z(i); end