我是一个新的 MATLAB 用户,我正在尝试绘制一个函数:
function [ uncertainty ] = uncertain(s1, s2, p)
%UNCERTAIN calculates the measurement uncertainty of a triangulation
% provide two coordinates of known stations and a target coordinate
% of another point, then you get the uncertainty
[theta1, dist1] = cart2pol(p(1)-s1(1), p(2)-s1(2));
[theta2, dist2] = cart2pol(p(1)-s1(1), p(2)-s2(2));
theta=abs(pi-theta2-theta1);
uncertainty = dist1*dist2/abs(sin(theta));
end
调用:
uncertain([0 0],[8 0],[4 4])
我得到一个结果。但我想要一个完整的表面并调用:
x=-2:.1:10;
y=-2:.1:10;
z = uncertain([0 0],[8 0],[x y]);
mesh(x,y,z)
我收到错误:“Z 必须是矩阵,而不是标量或向量。”
如何修改我的代码以便我的函数绘制一个表面?
提前致谢。拉尔夫。