MATLAB 中的 ezplot,如何使用函数句柄进行绘图?

ezplot in MATLAB, how to plot using a function handle?

我试过这个:

linefunca = @(xa,ya) aa*xa + ba*ya + ca;

figure(1)
imshow(Pica);
hold on;
ezplot(linefunca,[1,1072,1,712]);

但是我收到了这个错误:

 In an assignment  A(I) = B, the number of elements in B and I must be the same.

Error in ezplotfeval/applyfun (line 80)
       z(i) = feval(f,x(i),y(i));

Error in ezplotfeval (line 65)
    z = applyfun(x,y);

Error in ezplot>ezimplicit (line 257)
u = ezplotfeval(f, X, Y);

Error in ezplot (line 153)
            hp = ezimplicit(cax, f{1}, vars, labels, args{:});

Error in ps3 (line 313)
ezplot(linefunca,[1,1072,1,712]);

aabaca都是已知值(列向量)。 x 和 y 限制是我正在处理的图像的大小。我正在尝试绘制一组对极线。有什么建议吗?

编辑:

lt = length(aa);
linefunca = @(x,y,t) aa.*x(t) + ba.*y(t) + ca(t);
figure(1)
imshow(Pica);
hold on;

for t=1:lt
    ezplot(@(x,y,t) linefunca(x,y,t),[1,lt]);
end

据我所知,ezplot不能画出像plot这样的一系列线条。解决此问题的一种方法是向匿名函数添加参数 k,该函数用于 select 当前行。然后,您可以在 for 循环中遍历所有行并逐行绘制它们。

此外:正如 ezplot help page 中所述,您必须使用数组函数 .*./.^,因此 ezplot可以使用向量来计算函数。

N = 5;
aa = rand(N,1); ba = rand(N,1); ca = rand(N,1);
linefunca = @(xa,ya,k) aa(k).*xa + ba(k).*ya + ca(k);

hold on
for k=1:N
    ezplot(@(x,y)linefunca(x,y,k),[-5,5,-5,5]);
end
hold off