官方lookuptable函数帮助文档中的一个示例如下:
User-Specified Interpolation and Extrapolation Methods
This example is similar to the previous one, but it gives the block user control over the interpolation and extrapolation methods.
import simscape.enum.*
component tlu_2d_enum
inputs
u1 = 0;
u2 = 0;
end
outputs
f = 0;
end
parameters (Size=variable)
x1d = [1 2 3 4];
x2d = [1 2 3];
fd = [1 2 3; 3 4 5; 5 6 7; 7 8 9];
end
parameters
interp = interpolation.linear; % Interpolation method
extrap = extrapolation.linear; % Extrapolation method
end
equations
f == tablelookup(x1d, x2d, fd, u1, u2, interpolation=interp, extrapolation=extrap);
end
end
存为a1.m后,导入Matlab运行时,报错:
文件:a1.m 行:9 列:18
'=' 运算符的使用不正确。要为变量赋值,请使用 '='。要比较值是否相等,请使用 '=='。
请问内插和外插应该如何赋值?
你好,是不是
f == tablelookup(x1d, x2d, fd, u1, u2, interpolation=interp, extrapolation=extrap)
要改成
f = tablelookup(x1d, x2d, fd, u1, u2, interpolation=interp, extrapolation=extrap)