我有一个 0.1 弧度狭缝的网格。
mesh = makeSlitMesh(0.1,5)
它的内容
p: [2x188 double]
t: [3x330 double]
edges: [2x517 double]
t2e: [3x330 double]
e2t: [2x517 double]
我的get_solution_at_xy函数参数:
>> x = randn(100,1);
>> y = randn(100,1);
我运行代码如下的函数
get_solution_at_xy(@(x,y) sin(pi*x) .* sin(pi*y), 网格, x, y)
并得到错误
Error using TriScatteredInterp
Sample values must be a double array.
Error in get_solution_at_xy (line 18)
F=TriScatteredInterp(mesh.p(1,:)',mesh.p(2,:)',uh);
我已经转置了数组x和y,但仍然得到同样的错误。数组是双的。
什么会导致此错误?
get_solution_at_xy 函数
% Evaluates the FEM function "uh" defined on "mesh" at the points x,y
%
% CALLING SYNTAX IS
%
% function val = get_solution_at_xy(uh,mesh,x,y)
%
% uh = FEM function to be evaluated
% mesh = trimesh structure on which the FEM function is defined
% x = x coordinates of the evaluation points
% y = y coordinates of the evaluation points
%
% val = value of the FEM function evaluated at the points x,y
%
function val = get_solution_at_xy(uh,mesh,x,y)
F=TriScatteredInterp(mesh.p(1,:)',mesh.p(2,:)',uh);
val=F(x,y);
end